How to Report Powershell Version Using Custom Inventory
search cancel

How to Report Powershell Version Using Custom Inventory


Article ID: 179078


Updated On:


Inventory Solution




Custom Inventory can be used to detect what version of PowerShell is installed on computers. This article presents a sample custom inventory script and custom report that displays the custom inventory data. Please note that Symantec Support does not support custom scripting or reporting so modifications to the script and report must be made by the user.

Additional Information


1    Create a new custom data class that will store the registry information for each computer.

  • Go to Settings>All Settings then Settings>Discovery and Inventory>Inventory Solution>Manage Custom Data Classes.
  • Click New data class.
  • Name the data class something appropriate (the example later uses "PowerShell") and click OK. Use this exact data class name later in the custom inventory script.
  • Click Add attribute.
  • Name the something appropriate (the example later uses "Version"), set Key to "No", and click OK.
  • Click Save Changes at the bottom of the Manage Custom Data Classes page.

2   Create a Custom Inventory Script Task.

  • Go to Manage>Jobs and Tasks.
  • Browse the folder drop-down menu to an appropriate folder to create the custom inventory script task under.
  • Right-click on the folder, then select New>Task.
  • Select the Run Script task.
  • Name the task appropriately.
  • Select Script type: VBScript.
  • Copy and paste the entire vbscript below into the large text box of the script task, then edit the script as directed by the comments (noted by ‘****).
'Pick the appropriate WMI registry hive code and comment the line you don’t use
Const HKEY_LOCAL_MACHINE = &H80000002
Set wshShell = WScript.CreateObject( "WScript.Shell" )
ComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )

set nse = WScript.CreateObject ("Altiris.AeXNSEvent")
nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}" 'Do not modify this GUID
nse.Priority = 1
dim objDCInstance
set objDCInstance = nse.AddDataClass ("PowerShell") 'Your Data Class Here
set objDataClass = nse.AddDataBlock (objDCInstance)

KeyPath = "SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine" 'Your Registry Key Path Here
ValueName = "PowerShellVersion" 'Your Registy Entry Here
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

'Use the HKEY constant defined earlier and use the oReg function appropriate to the type of data in the registry entry
error_returned = oReg.GetStringValue(HKEY_LOCAL_MACHINE,KeyPath,ValueName,Value)
if error_returned <> 0 then
KeyPath = "SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine"
error_returned = oReg.GetStringValue(HKEY_LOCAL_MACHINE,KeyPath,ValueName,Value)
end if

set objDataRow = objDataClass.AddRow
objDataRow.SetField 0, Value
'If your data class has more than one attribute add a line for each
'objDataRow.SetField 1, Value2
'Uncomment the line below for testing purposes
'MsgBox nse.Xml

3    Run the Custom Inventory Script task.

  • Click on New Schedule, choose Now or specify a schedule time and repeat interval.
  • Specify target computers to run the task on.
  • To target a single computer click in the Quick add: box and search for the name of the computer, or use the Quick Run feature instead of New Schedule.
  • To target a list of computers click on Add>Computers or Devices then manually select the desired computers and click > and OK.
  • To target a computer filter (such as All Computers) click on Add>Target, click Add rule, choose exclude computers not in, and search the name of the filter in the final drop-down box, then click OK.

4    Create a Custom Report to view the data collected by the custom inventory.

  • Go to Reports>All Reports.
  • Browse to an appropriate folder to create the custom report under and right-click on the folder.
  • Select New>Report>SQL Report.
  • Give the report an appropriate name.
  • Replace the text under Parameterized Query with the following query:
select vc.[guid],, vc.[ip address], vc.[os name], ic.Version from Inv_PowerShell ic --Your custom data class table here
join vComputer vc on vc.[guid] = ic._ResourceGuid
  • Change "Inv_PowerShell" to "Inv_" then the name of the custom data class created in step 1. Replace spaces in the data class name with underscores (_).
  • Replace "ic.Version" with "ic." then the name of the attribute created in step 1.
  • Click Save Changes and then view the collected custom inventory data for each computer.