Configuring a GPO Logon Script to Run PC Inventory
Purpose: To Create or Modify a Group Policy Object (GPO) logon script.
Prerequsities: PC Inventory.
Add the following commands to an existing logon script, or paste them into a new batch file. Each command is defined below:
net start winmgmt sc config winmgmt start= auto netsh advfirewall firewall add rule dir=in name ="WMI" program=%systemroot%"system32"svchost.exe service=winmgmt action = allow protocol=TCP localport=any J: cscript.exe GetSysInfo.vbs net use J: /delete /yes exit |
Command Definitions:
- net start winmgmt - Start the WMI service
- sc config winmgmt start= auto - set the WMI service to start automatically
- netsh advfirewall firewall add rule dir=in name ="WMI" program=%systemroot%"system32"svchost.exe service=winmgmt action = allow protocol=TCP localport=any - Create a Windows Firewall exception for WMI queries
- net use J: /delete /yes - DELETES ANY CURRENT DRIVE MAP AT THE INDICATED LETTER
Note: The above "net use #: /delete " command is optional. However, if the drive letter is already in use, the script will not execute.
Note: The choice of drive letter used is also optional. We used "J" as an example.
- net use J: \\hiddenUNC\folder$ - Create a temporarily mapped drive to NovoRoot\pc_inventory\Current to execute the WMI query
- J: - Change to the mapped drive
- cscript.exe GetSysInfo.vbs - Executes the script
Note: The GetSysInfo.vbs will copy a file similar to "ComputerName_SystemInfo.xml" to the mapped drive
- net use J: /delete /yes - Deletes the mapped drive
- exit - close command prompt window