Here is a script I use when pushing certain apps when the advertisement is dependant on collection membership.
Note that the hardware inventory actually does pertain to installed apps.
'force hardware inventory for SMS client
On Error Resume Next
Set cpApplet = CreateObject("CPAPPLET.CPAppletMgr")
Set actions = cpApplet.GetClientActions
For Each action In actions
If Instr(action.Name,"Hardware Inventory") > 0 Then
action.PerformAction
End if
Next
---
Here is another script that does a full inventory
that I use more frequently than the aforementioned. Written by Chris Stauffer.
'***************************************************************************
' SMS Advanced Client WMI Class Creation and Inventory
' written by Chris Stauffer
'***************************************************************************
'Steps:
'1. Reset Hardware Inventory Action to force a full inventory collection
'2. Hardware Inventory Action
'3. Reset Software Inventory Action to force a full inventory collection
'4. Software Inventory Action
'***********************************************
'Declare Variables
On Error Resume Next
Set sho = CreateObject("WScript.Shell")
strSystemRoot = sho.expandenvironmentstrings("%SystemRoot%")
strCurrentDir = Left(Wscript.ScriptFullName, (InstrRev(Wscript.ScriptFullName, "\") -1))
' Get a connection to the "root\ccm\invagt" namespace (where the Inventory agent lives)
Dim oLocator
Set oLocator = CreateObject("WbemScripting.SWbemLocator")
Dim oServices
Set oServices = oLocator.ConnectServer( , "root\ccm\invagt")
'Reset SMS Hardware Inventory Action to force a full HW Inventory Action
sInventoryActionID = "{00000000-0000-0000-0000-000000000001}"
' Delete the specified InventoryActionStatus instance
oServices.Delete "InventoryActionStatus.InventoryActionID=""" & sInventoryActionID & """"
'Pause 3 seconds To allow the action to complete.
wscript.sleep 3000
'Run a SMS Hardware Inventory
Set cpApplet = CreateObject("CPAPPLET.CPAppletMgr")
Set actions = cpApplet.GetClientActions
For Each action In actions
If Instr(action.Name,"Hardware Inventory") > 0 Then
action.PerformAction
End If
Next
'Reset SMS Hardware Inventory Action to force a full HW Inventory Action
sInventoryActionID = "{00000000-0000-0000-0000-000000000002}"
' Delete the specified InventoryActionStatus instance
oServices.Delete "InventoryActionStatus.InventoryActionID=""" & sInventoryActionID & """"
'Pause 3 seconds To allow the action to complete.
wscript.sleep 3000
'Run a SMS Software Inventory
Set cpApplet = CreateObject("CPAPPLET.CPAppletMgr")
Set actions = cpApplet.GetClientActions
For Each action In actions
If Instr(action.Name,"Software Inventory Collection Cycle") > 0 Then
action.PerformAction
End If
Next