15 May 2013

Initiate Hardware Inventory

Posted By: Mick Pletcher - 12:56 PM

Share

& Comment


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  

About Mick Pletcher

My blog is here to help solve issues I have encountered and solved, publish scripts I have written, and educate others in understanding areas that are not well covered

0 comments:

Post a Comment

Copyright © 2013 Mick's IT Blogs™ is a registered trademark.