I am writing a Custom Inventory Rule to list the mapped network Drives of a Node. I have used both of the following rules:

ShellCommandTextReturn(cmd /c net use )

And

ShellCommandTextReturn (cmd /c wmic logicaldisk get caption,description,drivetype,providername,volumename)


Both seem to work. Problem is both return the output from an adminstator shell and not a regular shell.


Output from "ShellCommandTextReturn(cmd /c net use )" :

"New connections will be remembered.

There are no entries in the list."



Output from "ShellCommandTextReturn (cmd /c wmic logicaldisk get caption,description,drivetype,providername,volumename)":

"Caption Description DriveType ProviderName VolumeName
C: Local Fixed Disk 3 "


Desired Results:

ShellCommandTextReturn(cmd /c net use )

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
OK           S:       
\\someserver\software       Microsoft Windows Network
OK           U:       
\\someserver\somefolder\somename
                                                Microsoft Windows Network
Disconnected X:       
\\someserver\somename         Microsoft Windows Network
OK                    
\\someserver\somename Microsoft Windows Network


ShellCommandTextReturn (cmd /c wmic logicaldisk get caption,description,drivetype,providername,volumename)

Caption  Description         DriveType  ProviderName                     VolumeName
C:       Local Fixed Disk    3
S:       Network Connection  4         
\\someserver\software              Some Volume 3
U:       Network Connection  4         
\\someserver\somefolder\somename  Some Volume 1
X:       Network Connection  4         
\\someserver\somename              New Volume 2


Any suggestions or a different approach such and exporting the output from the registry appreciated.



Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answer Chosen by the Author

1
Like Chuck said CIR's run as system and network drives are a user thing.  You need to create a Kscript that creates a txt to have the cir read for this to work.

Here is a script of mine that gathers user based info for CIR's to read.

Here is the batch file it runs
wmic logicaldisk where "drivetype='4'" get deviceid,providername > C:\ProgramData\Dell\KACE\user\NetworkDrives.txt

wmic printer where 'network="true"' get name, default, network > C:\ProgramData\Dell\KACE\user\NetworkPrinters.txt

wmic printer where "network=false and NOT DriverName LIKE '%%WebEx%%' and NOT DriverName LIKE '%%Amyuni%%' and NOT DriverName LIKE '%%Microsoft%%' and NOT DriverName LIKE '%%PDF%%' and NOT DriverName LIKE '%%Adobe%%' and NOT DriverName LIKE '%%Hyland%%' and NOT DriverName LIKE '%%snagit%%'" get name,drivername,printerstatus > C:\ProgramData\Dell\KACE\user\LocalPrinters.txt

wmic printer where "NOT DriverName LIKE '%%WebEx%%' and NOT DriverName LIKE '%%Amyuni%%' and NOT DriverName LIKE '%%Microsoft%%' and NOT DriverName LIKE '%%PDF%%' and NOT DriverName LIKE '%%Adobe%%' and NOT DriverName LIKE '%%Hyland%%' and NOT DriverName LIKE '%%snagit%%'" get name,drivername,portname > C:\ProgramData\Dell\KACE\user\AllPrinters.txt

c:\windows\system32\reg.exe query hkcu\software\microsoft\windows\currentversion\run /s > C:\ProgramData\Dell\KACE\user\hkcuRunKeys.txt

c:\windows\system32\reg.exe query hkcu\software\microsoft\windows\currentversion\uninstall /s /f DisplayName > C:\ProgramData\Dell\KACE\user\hkcuSoftware.txt

c:\windows\system32\reg.exe query hkcu\software\wow6432node\microsoft\windows\currentversion\run /s > C:\ProgramData\Dell\KACE\user\hkcuRunKeysx64.txt

c:\windows\system32\reg.exe query hkcu\software\wow6432node\microsoft\windows\currentversion\uninstall /s /f DisplayName > C:\ProgramData\Dell\KACE\user\hkcuSoftwarex64.txt

c:\windows\system32\reg.exe query "HKCU\Software\Shoreline Teleworks\ShoreWare Client" /v server > C:\ProgramData\Dell\KACE\user\shoretell.txt

You then create CIR's to read the text files




Answered 08/29/2016 by: SMal.tmcc
Red Belt

Please log in to comment

Community Chosen Answer

1
The issue is that custom inventory rules run in the system context and the drives are mapped in the user context. The other issue is that these values will get updated every time the computer updates it's inventory, so if the computer updates inventory when no user is logged in, then your data won't be accurate.

Answered 08/26/2016 by: chucksteel
Red Belt

Please log in to comment

Answers

-1
You might be able to adapt the script from the following link. Place it in the programdata\dell\kace folder and call it from the CIR.

https://social.technet.microsoft.com/Forums/windowsserver/en-US/46881e57-62a4-446e-af2d-cd2423e7837f/report-on-remote-users-mapped-drives?forum=winserverpowershell

Answered 08/27/2016 by: flip1001
Fourth Degree Green Belt

Please log in to comment
Answer this question or Comment on this question for clarity

Share