02/22/2019 329 views

Hello everyone,

Does anyone had tried to create a custom inventory rule for SMA  or something similar to collect that Map Drives names\shares?

this will become handy in case we need to look back and reconnect users after redoing their computers. Our environment does not have computers joined to the domain.

I'm trying to integrate something and get results like from this page:


any tip will help,

Thank you!

Answer Summary:
2 Comments   [ + ] Show comments


  • net use >C:\Install\Scripts\Drives.txt
    • If you run that as a CIR it will run as system and not work. Mapped drives are a users item not a machine item, so you must query for them as the user.
      • Yes sir, we run it as a script and then use the Custom Inventory to pull the text file it creates.
  • The return you are getting are the SYSTEMS mapped drives not the USERS. Yes you get a return but it is not true. If you go to the computer and open a command window as the user you will see different results then what you see in the CIR return. You need to run the command as the user and the only way to do that in the SMA is thru Kscripts.
    • a quick way to see this is login as a user that has mapped drives. Open a cmd as that user and one as administrator. run the net use in both windows

Answer Chosen by the Author


Mapped drives are a user function.  You need to use a kscript that runs a logged in user and runs every few hours (custom schedule 0 10,12,14,16 * * 1,2,3,4,5) to collect the information in text files you then read with CIR's  I use a online shell script

wmic logicaldisk where "drivetype='4'" get deviceid,providername > C:\ProgramData\quest\KACE\user\NetworkDrives.txt

wmic printer where 'network="true"' get name, default, network > C:\ProgramData\quest\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\quest\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\quest\KACE\user\AllPrinters.txt

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

c:\windows\system32\reg.exe query HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\PublishingWizard\AddNetworkPlace\AddNetPlace\LocationMRU > C:\ProgramData\quest\kace\user\hkcuNetplace.txt

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

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

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

dir %temp%\*.exe > C:\temp\exes.txt

The name of the output text files tells what each call does.

You create CIR's to read the files.


Shellcommandtextreturn(cmd /c if exist C:\ProgramData\quest\kace\user\hkcuNetplace.txt type C:\ProgramData\quest\kace\user\hkcuNetplace.txt)

Answered 02/22/2019 by: SMal.tmcc
Red Belt

  • Thanks, SMal.tmcc!

    Man...I was so far away from how it supposed to be done, I'm now able to see that info that I was looking for.

    Thanks again!
  • Getting an error on Windows 10 with the first line:
    wmic logicaldisk where "drivetype='4'" get deviceid,providername > C:\ProgramData\quest\KACE\user\NetworkDrives.txt

    CMD and PS both return "No Instance(s) Available." error and the file is not created.
    • Are you running the script as logged on user? if you run as administrator or the default of system it will give that result.
      • Ah, thanks! Was running locally in CMD/Powershell (as admin...) for testing and that caused the error. Non admin worked properly.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login