List Mapped drives
Hi,
I am trying to get list of mapped drives and searched - so far what I've found is not producing the txt file, I cannot get it to work. I have a CIR ShellCommandTextReturn (cmd.exe /c type C:\temp\mapped.txt) and its not returning any result. What am I missing? I am on v5.4.76847.
Tahnk you,
-
how are you creating the mapped.txt file? - SMal.tmcc 11 years ago
-
This is how I was doing it as a CIR ShellCommandTextReturn(cmd.exe /c type C:\temp\mapped.txt) but dugullett's comment makes sense this is running as a system and not producing any results. - bozadmin 11 years ago
Answers (5)
I think you will just want to put your command in there directly in lieu of c:\temp\mapped.txt.
For ex:
ShellCommandTextReturn(cmd /c net use)
I use the above example for a couple of other commands and it works...
It will spit the output in your Custom Inventory Fields section listed in the computer inventory.
Comments:
-
This is the same command I would use. - sikeswj 11 years ago
-
Jegolf- thanks for the quick reply. I tried the command ShellCommandTextReturn(cmd /c net use) and it returned nothing.
1) CIR - Mapped Drives: New connections will be remembered.
There are no entries in the list.
[string]
Thanks, - bozadmin 11 years ago-
I don't believe that will work because it's running as SYSTEM. It looks like you may have a space in your original command line in between the ShellCommandTextReturn and the first (. You need to remove that to read the .txt file. - dugullett 11 years ago
-
That was just a typo but if I put it in this way ShellCommandTextReturn(cmd.exe /c type C:\temp\mapped.txt) I get nothing. - bozadmin 11 years ago
-
Do you have the correct OSs selected? - dugullett 11 years ago
-
I am getting the same error as OP. This is my syntax ShellCommandTextReturn(cmd /c net use) I am on V5.5 - Netpar 11 years ago
-
Apologies for the lead in the wrong direction. You may need to look at running a script and not a custom inventory rule so you can run it under the current user's context. A quick Google finds many examples to try or someone here may have one in the bag already... - jegolf 11 years ago
dugullett has given you the reason it is not working. Any code running in SYSTEM context has NO access to any network resources so will not be able to see any mapped drives, as mapped drives exist in USER context. Any code that seeks to establish drive mapping for a specific user needs to run in the context of that user. Perhaps if you explain what you are trying to achieve, a more viable solution might be proposed
Comments:
-
It makes sense. What I am trying to do is: I found out from some of our junior admins that they have been mapping drives manually and need to push out login script. But before I do that I would like to to know who is mapped to what so I can account for that and maybe remap the drive for them. I just need to know who is mapped to what network drive. Is there a way I can do this as a script and run it as under current user? - bozadmin 11 years ago
try net use C:\temp\drives.txt
Comments:
-
This would still be the same issue and will be running under system and not user profile. - bozadmin 11 years ago
Any other suggestion? I need to figure a way to do this thing.
Comments:
-
Is the .txt file showing results? Is Kace just not inventorying it? - dugullett 11 years ago
-
its not creating the txt file and after doing agent debug seems like there is sytax error.
[Wed Nov 06 16:38:01 2013] [CDeployController::ExecuteCustomInventoryRule] issuing rule [ShellCommandTextReturn(cmd.exe /c type C:\temp\mapped.txt);]
[Wed Nov 06 16:38:01 2013] haveTokenLsaPriv returning: 1
[Wed Nov 06 16:38:01 2013] KLaunchProcess: Call CreateProcess to launch 'KLaunch.exe . -wait -hide -stdout "C:\Windows\TEMP\dklA0F3.tmp" cmd.exe /c type C:\temp\mapped.txt':
[Wed Nov 06 16:38:01 2013] KLaunchProcess: Wait for process to complete
[Wed Nov 06 16:38:03 2013] KLaunchProcess: process completed status=1
[Wed Nov 06 16:38:03 2013] [CDeployController::ExecuteCustomInventoryRule] statement result: "", FALSE
[Wed Nov 06 16:38:03 2013] KDeploy finished processing 7 custominventory rules, sending response - bozadmin 11 years ago-
Take a look at John's post on this. This script will run, and create a .txt file at c:\windows\KBOX\local_and_network_drives.txt. You then use your custom inventory rule to read that .txt file.
http://www.itninja.com/question/extending-the-computer-inventory-to-support-user-profile-specific-other-non-inventoried-data - dugullett 11 years ago
Thank you all for all the help and support you provide.
With the Help of Support I was able to get it working.
We ran it as Online Shell Script with Net use > "C:\Windows\Temp\mapped.txt"
Then use CIR ShellCommandTextReturn(cmd /c type "C:\Windows\Temp\mapped.txt")
To get it into Inventory.
Thank you,