15 May 2013

Initiate Hardware Inventory

Here is the scripting code in both powershell and VBScript to initiate a hardware inventory in both SMS and SCCM. The backend calls are the same in both SMS and SCCM, so both scripts will work in either app.

Powershell
 Function InitiateHardwareInventory{  
      $SCCMClient = [wmiclass] "\\localhost\root\ccm:SMS_Client"  
      $SCCMClient.TriggerSchedule("{00000000-0000-0000-0000-000000000001}")  
 }  


VBScript
 Sub InitiateHardwareInventory()  
      On Error Resume Next  
      DIM oCPAppletMgr  : Set oCPAppletMgr  = CreateObject("CPApplet.CPAppletMgr")  
      DIM oClientAction : Set oClientAction = Nothing  
      DIM oClientActions : Set oClientActions = oCPAppletMgr.GetClientActions()  
      For Each oClientAction In oClientActions  
           If oClientAction.Name = "Hardware Inventory Collection Cycle" Then  
                oClientAction.PerformAction  
           End If  
      Next  
 End Sub  

0 comments:

Post a Comment