Tuesday, October 20, 2015

Invoke SCCM Client Tasks

I recently had need to invoke the location services task on an SCCM client, and wanted to explore how WMI might be used to call this task.
I knew the client used the root\ccm namespace and after some digging, I found that the SMS_Client Class contained the TriggerSchedule method.  I used wbemtest.exe (available on any machine with WMI) and good old fashioned googling to poke around.  The SCCM 2012 r2 Toolkit contains a file called  SendScheduleMethods.xml, which has a full list of methods you can call (I've included them at the end).

Here's a quick and dirty oneliner I used to invoke my Location Services task:
  1. Invoke-CimMethod -ClassName SMS_Client -MethodName TriggerSchedule -Arguments @{sScheduleID='{00000000-0000-0000-0000-000000000025}'}  -Namespace root/ccm​
I checked the ClientLocation.log in C:\Windows\CCM\Logs and it was indeed up and running.  Fun times were had.  ​

{00000000-0000-0000-0000-000000000001}
HARDWARE_INV_ACTION_ID
Hardware Inventory
{00000000-0000-0000-0000-000000000002}
SOFTWARE_INV_ACTION_ID
Software Inventory
{00000000-0000-0000-0000-000000000003}
DISCOVERY_INV_ACTION_ID
Discovery Inventory
{00000000-0000-0000-0000-000000000010}
FILE_COLLECTION_ACTION_ID
File Collection
{00000000-0000-0000-0000-000000000011}
IDMIF_COLLECTION_ACTION_ID
IDMIF Collection
{00000000-0000-0000-0000-000000000012}
CLIENT_MACHINE_AUTH_ACTION_ID
Client Machine Authentication
{00000000-0000-0000-0000-000000000021}
POLICYAGENT_REQUEST_MACHINE_ASSIGNMENTS_ID
Request Machine Assignments
{00000000-0000-0000-0000-000000000022}
POLICYAGENT_EVALUATE_MACHINE_POLICIES_ID
Evaluate Machine Policies
{00000000-0000-0000-0000-000000000023}
LS_SCHEDULEDCLEANUP_REFRESH_DEFAULT_MP_TASK_ID
Refresh Default MP Task
{00000000-0000-0000-0000-000000000024}
LS_SCHEDULEDCLEANUP_REFRESH_LOCATIONS_TASK_ID
LS (Location Service) Refresh Locations Task
{00000000-0000-0000-0000-000000000025}
LS_SCHEDULEDCLEANUP_TIMEOUT_REFRESH_TASK_ID
LS (Location Service) Timeout Refresh Task
{00000000-0000-0000-0000-000000000026}
POLICYAGENT_REQUEST_USER_ASSIGNMENTS_ID
Policy Agent Request Assignment (User)
{00000000-0000-0000-0000-000000000027}
POLICYAGENT_EVALUATE_USER_POLICIES_ID
Policy Agent Evaluate Assignment (User)
{00000000-0000-0000-0000-000000000031}
SWMTR_USER_REPORT_GENERATION_ID
Software Metering Generating Usage Report
{00000000-0000-0000-0000-000000000032}
SOURCE_UPDATE_MESSAGE_ID
Source Update Message
{00000000-0000-0000-0000-000000000037}
Schedule for clearing proxy settings cache
Clearing proxy settings cache
{00000000-0000-0000-0000-000000000040}
[Machine Policy schedules] PolicyAgent_Cleanup
Machine Policy Agent Cleanup
{00000000-0000-0000-0000-000000000041}
[User Policy schedules] PolicyAgent_Cleanup
User Policy Agent Cleanup
{00000000-0000-0000-0000-000000000042}
[Machine Policy schedules] PolicyAgent_RequestAssignments
Policy Agent Validate Machine Policy / Assignment
{00000000-0000-0000-0000-000000000043}
[User Policy schedules] PolicyAgent_RequestAssignments
Policy Agent Validate User Policy / Assignment
{00000000-0000-0000-0000-000000000051}
Schedule for retrying/refreshing certificates in AD on MP
Retrying/Refreshing certificates in AD on MP
{00000000-0000-0000-0000-000000000061}
PDP_STATUS_REPORTING_SCHEDULE_ID
Peer DP Status reporting
{00000000-0000-0000-0000-000000000062}
PDP_PENDING_PACKAGE_CHECK_SCHEDULE_ID
Peer DP Pending package check schedule
{00000000-0000-0000-0000-000000000063}
SUM_UPDATES_INSTALL_SCHEDULE_ID
SUM Updates install schedule
{00000000-0000-0000-0000-000000000071}
NAP_ACTION_ID
NAP action
{00000000-0000-0000-0000-000000000101}
HARDWARE_INV_POLICY_ACTION_ID
Hardware Inventory Collection Cycle
{00000000-0000-0000-0000-000000000102}
SOFTWARE_INV_POLICY_ACTION_ID
Software Inventory Collection Cycle
{00000000-0000-0000-0000-000000000103}
DISCOVERY_INV_POLICY_ACTION_ID
Discovery Data Collection Cycle
{00000000-0000-0000-0000-000000000104}
FILE_COLLECTION_POLICY_ACTION_ID
File Collection Cycle
{00000000-0000-0000-0000-000000000105}
IDMIF_COLLECTION_POLICY_ACTION_ID
IDMIF Collection Cycle
{00000000-0000-0000-0000-000000000106}
METRING_POLICY_ACTION_ID
Software Metering Usage Report Cycle
{00000000-0000-0000-0000-000000000107}
SOURCE_UPDATE_POLICY_ACTION_ID
Windows Installer Source List Update Cycle
{00000000-0000-0000-0000-000000000108}
SOFTWARE_UPDATES_POLICY_ACTION_ID
Software Updates Assignments Evaluation Cycle
{00000000-0000-0000-0000-000000000109}
PDP_MAINTENANCE_POLICY_ACTION_ID
Branch Distribution Point Maintenance Task
{00000000-0000-0000-0000-000000000110}
DCM_POLICY_ACTION_ID
DCM policy
{00000000-0000-0000-0000-000000000111}
STATE_SYSTEM_POLICY_BULKSEND_ACTION_ID
Send Unsent State Message
{00000000-0000-0000-0000-000000000112}
STATE_SYSTEM_POLICY_CACHECLEANOUT_ACTION_ID
State System policy cache cleanout
{00000000-0000-0000-0000-000000000113}
UPDATE_SOURCE_POLICY_ACTION_ID
Scan by Update Source
{00000000-0000-0000-0000-000000000114}
UPDATE_STORE_POLICY_ACTION_ID
Update Store Policy
{00000000-0000-0000-0000-000000000115}
STATE_SYSTEM_POLICY_BULKSEND_HIGH_ACTION_ID
State system policy bulk send high
{00000000-0000-0000-0000-000000000116}
STATE_SYSTEM_POLICY_BULKSEND_LOW_ACTION_ID
State system policy bulk send low
{00000000-0000-0000-0000-000000000120}
AMT_STATUS_CHECK_POLICY_ACTION_ID
AMT Status Check Policy
{00000000-0000-0000-0000-000000000121}
APPMAN_POLICY_ACTION_ID
Application manager policy action
{00000000-0000-0000-0000-000000000122}
APPMAN_USER_POLICY_ACTION_ID
Application manager user policy action
{00000000-0000-0000-0000-000000000123}
APPMAN_GLOBAL_EVALUATION_ACTION_ID
Application manager global evaluation action
{00000000-0000-0000-0000-000000000131}
PWRMGMT_START_SUMMARIZER_ID
Power management start summarizer
{00000000-0000-0000-0000-000000000221}
EP_DEPLOYMENT_REEVALUATE_ID
Endpoint deployment reevaluate
{00000000-0000-0000-0000-000000000222}
EP_AMPOLICY_REEVALUATE_ID
Endpoint AM policy reevaluate
{00000000-0000-0000-0000-000000000223}
EXTERNAL_EVENT_DETECTION_ID
External event detection