Chris Stauffer at myITForum.com

You want me to do What?

Syndication

News

Links to blogs i like

Links

Script to perform a full SMS inventory

This script will cause a full Software and Hardware scan for SMS 2003 Advanced Client.

 This comes in handy when you want to make sure that the inventory has gotten everything.

Full_inventory_now.vbs

'***************************************************************************

'  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

 

Published Wednesday, April 04, 2007 2:09 PM by cstauffer
Filed under:

Comments

No Comments