Custom Inventory Rule to List Mapped Network Drives
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.
Answers (3)
Top Answer
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