Eswar Koneti's Blog

All about Configmgr and its connected objects…….

  • About Author
      View eswar koneti's LinkedIn profile
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 99 other subscribers

  • Awards


  • FaceBook Updates

  • Catagories

  • Meta

  • Copyright!

    All the blog posts in this website are owned by Eswar Koneti and may not be reused in any mode without prior approval of Eswar Koneti. You may quote one paragraph from the blog posts if you link to the original blog post.
    Happy Reading!

script to trigger Machine policy or Hardware inventory action agent on SCCM clients

Posted by Eswar Koneti on 11th January 2011

There are lot of tools available like SCCM client center or Collection commander or Right Click Tools etc. to trigger SCCM client agent Actions using these tools but the customer environment doesn’t have any of these tools to use and we had a requirement to run the machine policy and other actions items as well.

I have used the below script to run(ex:Machine policy and evaluation cycle or hardware inventory action etc) on a list of computers that you have supplied in notepad.txt using psexec tool.The script reset the hardware inventory action and deletes the instance before running hardware inventory.

What do you require to carry out this task: A Share folder(create one) ,Psexec tool, Vb script(below) and batch script(below).

Open a notepad,copy the below code and save as trigger_policy.vbs.

‘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

since the above script you have created is to trigger hardware inventory action,You will have all the Actions ID given below for each.

    • Hardware Inventory – 00000000-0000-0000-0000-000000000001
    • Software Inventory – 00000000-0000-0000-0000-000000000002
    • Data Discovery – 00000000-0000-0000-0000-000000000003
    • Machine Policy Assignment Request – 00000000-0000-0000-0000-000000000021
    • Machine Policy Evaluation – 00000000-0000-0000-0000-000000000022
    • Refresh Default Management Point – 00000000-0000-0000-0000-000000000023
    • Refresh Location (AD site or Subnet) – 00000000-0000-0000-0000-000000000024
    • Software Metering Usage Reporting – 00000000-0000-0000-0000-000000000031
    • Source list Update Cycle – 00000000-0000-0000-0000-000000000032
    • Refresh proxy management point – 00000000-0000-0000-0000-000000000037
    • Cleanup policy – 00000000-0000-0000-0000-000000000040
    • Validate assignments – 00000000-0000-0000-0000-000000000042
    • Certificate Maintenance – 00000000-0000-0000-0000-000000000051
    • Branch DP Scheduled Maintenance – 00000000-0000-0000-0000-000000000061
    • Branch DP Provisioning Status Reporting – 00000000-0000-0000-0000-000000000062
    • Software Update Deployment – 00000000-0000-0000-0000-000000000108
    • State Message Upload – 00000000-0000-0000-0000-000000000111
    • State Message Cache Cleanup – 00000000-0000-0000-0000-000000000112
    • Software Update Scan – 00000000-0000-0000-0000-000000000113
    • Software Update Deployment Re-eval – 00000000-0000-0000-0000-000000000114
    • OOBS Discovery – 00000000-0000-0000-0000-000000000120

You can see all the above actions item IDs from WMI. From Run command,type wbemtest and use the name space as ‘root\CCM\Policy\Machine‘. It list all the classes (Dynamic or Static from WMI Repository).

Again,open notepad and copy the below code into it and save as name.bat

@Echo off
REM Initiating Hardware inventory agent action
cd d:\script
d:
psexec @computers.txt -c \\Servername\actions\trigger_policy.vbs

Exit

 

Now run the batch script which you created above from either command prompt or directly from folder.

Hope it helps someone who doesn’t use the automated tools.

Have blogged the same post on http://wmug.co.uk/blogs/eskonr/archive/2011/01/12/how_2D00_to_2D00_trigger_2D00_sccm_2D00_machine_2D00_policy_2D00_or_2D00_hardware_2D00_inventory_2D00_action_2D00_agent_2D00_on_2D00_remote_2D00_computers.aspx

Tags: , , , , , , , , , , , ,
Posted in SCCM 2007, SCCM 2012, Scripting, Software Distribution, Trobleshooting Tips, Troubleshooting Issues, WMI | 5 Comments »