Triggering ConfigMgr Client Actions from a Task Sequence

This week, we were working on testing Windows 7 to Windows 10 In-Place Upgrades and ran into an issue where our clients weren’t updating their Operating System version in the ConfigMgr console. After some helpful responses on Twitter, I was able to add a client action trigger step to the end of my Task Sequence. In my production environment, we have a child task sequence that we call that has several client action steps in it including Request Machine Assignments (Machine Policies) {00000000-0000-0000-0000-000000000021}, Hardware Inventory {00000000-0000-0000-0000-000000000001} and now a Discovery Inventory {00000000-0000-0000-0000-000000000003}.

The idea behind this Task Sequence is to create a Run Command Line step for each of the ConfigMgr client schedule IDs. From there, the sky’s the limit. It just seemed like a great way to just get them all into one place for easy access. You can add it to your Task Sequence as a child Task Sequence or even advertise it as a standalone Task Sequence for newly imaged devices. Additionally, if you want to know what each item does or which logs to look into, just Google it. That’s what I did! 🙂

Some people may ask why not just put all of the actions I want into a script. Because I don’t want to. There are scripts out there that do this same thing in Powershell, but I wanted steps that would be easy for anyone to enable/disable without having to dig into a separate script to debug or change things.

Just use caution. Test! Test! Test!

DISCLAIMER

Use with caution and test in your lab first. Also, I have not tested all of these actions. Some of them may be deprecated. The list came from here

Script to Create Task Sequence

I stole the base code for this from Johan Arwidmark’s (@jarwidmark) Creating Task Sequences in ConfigMgr via PowerShell blog post. The script is simple. Customize it as you see fit. It creates a list of actions that get added to an Enabled and Disabled group in a new Task Sequence. The Disabled Group is set to Disabled in the Task Sequence, but each item below it is not, can move steps in and out of the groups in your TS easily once you’ve created the Task Sequence.

You will need to connect to your ConfigMgr site to run this. The easiest way to do that is to open the ConfigMgr Console and click the upper left corner menu. Select Connect vis Windows PowerShell ISE. Then run the script that pops up. Don’t edit that script! Once in ISE, copy the following code into a new window, customize it and run it.

 1$ClientActions = @()
 2
 3#number of seconds the script will sleep before triggering the next action. This gets set on each commandline.
 4#Set to 0 to skip sleep.
 5$SleepInSeconds = 120
 6
 7#Comment Out any client actions that you don't want to add to your TS.
 8
 9#Move actions here that will be added to the Enabled Client Actions group.
10$EnabledActions = @()
11$EnabledActions += [pscustomobject]@{ ActionName =  'Request Machine Assignments'; ActionID = '{00000000-0000-0000-0000-000000000021}' }
12$EnabledActions += [pscustomobject]@{ ActionName =  'Hardware Inventory'; ActionID = '{00000000-0000-0000-0000-000000000001}' }
13$EnabledActions += [pscustomobject]@{ ActionName =  'Discovery Inventory'; ActionID = '{00000000-0000-0000-0000-000000000003}' }
14
15#Move actions here that will be added to the Disabled Client Actions group.
16#These are simply added to the TS so that they are available if you need them.
17#You can comment out the ProcessActions step at the end of the script if you would like to exclude these altogether.
18$DisabledActions = @()
19$DisabledActions += [pscustomobject]@{ ActionName =  'Software Inventory'; ActionID = '{00000000-0000-0000-0000-000000000002}' }
20$DisabledActions += [pscustomobject]@{ ActionName =  'File Collection'; ActionID = '{00000000-0000-0000-0000-000000000010}' }
21$DisabledActions += [pscustomobject]@{ ActionName =  'IDMIF Collection'; ActionID = '{00000000-0000-0000-0000-000000000011}' }
22$DisabledActions += [pscustomobject]@{ ActionName =  'Client Machine Authentication'; ActionID = '{00000000-0000-0000-0000-000000000012}' }
23$DisabledActions += [pscustomobject]@{ ActionName =  'Evaluate Machine Policies'; ActionID = '{00000000-0000-0000-0000-000000000022}' }
24$DisabledActions += [pscustomobject]@{ ActionName =  'Refresh Default MP Task'; ActionID = '{00000000-0000-0000-0000-000000000023}' }
25$DisabledActions += [pscustomobject]@{ ActionName =  'LS (Location Service) Refresh Locations Task'; ActionID = '{00000000-0000-0000-0000-000000000024}' }
26$DisabledActions += [pscustomobject]@{ ActionName =  'LS (Location Service) Timeout Refresh Task'; ActionID = '{00000000-0000-0000-0000-000000000025}' }
27$DisabledActions += [pscustomobject]@{ ActionName =  'Policy Agent Request Assignment (User)'; ActionID = '{00000000-0000-0000-0000-000000000026}' }
28$DisabledActions += [pscustomobject]@{ ActionName =  'Policy Agent Evaluate Assignment (User)'; ActionID = '{00000000-0000-0000-0000-000000000027}' }
29$DisabledActions += [pscustomobject]@{ ActionName =  'Software Metering Generating Usage Report'; ActionID = '{00000000-0000-0000-0000-000000000031}' }
30$DisabledActions += [pscustomobject]@{ ActionName =  'Source Update Message'; ActionID = '{00000000-0000-0000-0000-000000000032}' }
31$DisabledActions += [pscustomobject]@{ ActionName =  'Clearing proxy settings cache'; ActionID = '{00000000-0000-0000-0000-000000000037}' }
32$DisabledActions += [pscustomobject]@{ ActionName =  'Machine Policy Agent Cleanup'; ActionID = '{00000000-0000-0000-0000-000000000040}' }
33$DisabledActions += [pscustomobject]@{ ActionName =  'User Policy Agent Cleanup'; ActionID = '{00000000-0000-0000-0000-000000000041}' }
34$DisabledActions += [pscustomobject]@{ ActionName =  'Policy Agent Validate Machine Policy / Assignment'; ActionID = '{00000000-0000-0000-0000-000000000042}' }
35$DisabledActions += [pscustomobject]@{ ActionName =  'Policy Agent Validate User Policy / Assignment'; ActionID = '{00000000-0000-0000-0000-000000000043}' }
36$DisabledActions += [pscustomobject]@{ ActionName =  'Retrying/Refreshing certificates in AD on MP'; ActionID = '{00000000-0000-0000-0000-000000000051}' }
37$DisabledActions += [pscustomobject]@{ ActionName =  'Peer DP Status reporting'; ActionID = '{00000000-0000-0000-0000-000000000061}' }
38$DisabledActions += [pscustomobject]@{ ActionName =  'Peer DP Pending package check schedule'; ActionID = '{00000000-0000-0000-0000-000000000062}' }
39$DisabledActions += [pscustomobject]@{ ActionName =  'SUM Updates install schedule'; ActionID = '{00000000-0000-0000-0000-000000000063}' }
40$DisabledActions += [pscustomobject]@{ ActionName =  'NAP action'; ActionID = '{00000000-0000-0000-0000-000000000071}' }
41$DisabledActions += [pscustomobject]@{ ActionName =  'Hardware Inventory Collection Cycle'; ActionID = '{00000000-0000-0000-0000-000000000101}' }
42$DisabledActions += [pscustomobject]@{ ActionName =  'Software Inventory Collection Cycle'; ActionID = '{00000000-0000-0000-0000-000000000102}' }
43$DisabledActions += [pscustomobject]@{ ActionName =  'Discovery Data Collection Cycle'; ActionID = '{00000000-0000-0000-0000-000000000103}' }
44$DisabledActions += [pscustomobject]@{ ActionName =  'File Collection Cycle'; ActionID = '{00000000-0000-0000-0000-000000000104}' }
45$DisabledActions += [pscustomobject]@{ ActionName =  'IDMIF Collection Cycle'; ActionID = '{00000000-0000-0000-0000-000000000105}' }
46$DisabledActions += [pscustomobject]@{ ActionName =  'Software Metering Usage Report Cycle'; ActionID = '{00000000-0000-0000-0000-000000000106}' }
47$DisabledActions += [pscustomobject]@{ ActionName =  'Windows Installer Source List Update Cycle'; ActionID = '{00000000-0000-0000-0000-000000000107}' }
48$DisabledActions += [pscustomobject]@{ ActionName =  'Software Updates Assignments Evaluation Cycle'; ActionID = '{00000000-0000-0000-0000-000000000108}' }
49$DisabledActions += [pscustomobject]@{ ActionName =  'Branch Distribution Point Maintenance Task'; ActionID = '{00000000-0000-0000-0000-000000000109}' }
50$DisabledActions += [pscustomobject]@{ ActionName =  'DCM policy'; ActionID = '{00000000-0000-0000-0000-000000000110}' }
51$DisabledActions += [pscustomobject]@{ ActionName =  'Send Unsent State Message'; ActionID = '{00000000-0000-0000-0000-000000000111}' }
52$DisabledActions += [pscustomobject]@{ ActionName =  'State System policy cache cleanout'; ActionID = '{00000000-0000-0000-0000-000000000112}' }
53$DisabledActions += [pscustomobject]@{ ActionName =  'Scan by Update Source'; ActionID = '{00000000-0000-0000-0000-000000000113}' }
54$DisabledActions += [pscustomobject]@{ ActionName =  'Update Store Policy'; ActionID = '{00000000-0000-0000-0000-000000000114}' }
55$DisabledActions += [pscustomobject]@{ ActionName =  'State system policy bulk send high'; ActionID = '{00000000-0000-0000-0000-000000000115}' }
56$DisabledActions += [pscustomobject]@{ ActionName =  'State system policy bulk send low'; ActionID = '{00000000-0000-0000-0000-000000000116}' }
57$DisabledActions += [pscustomobject]@{ ActionName =  'AMT Status Check Policy'; ActionID = '{00000000-0000-0000-0000-000000000120}' }
58$DisabledActions += [pscustomobject]@{ ActionName =  'Application manager policy action'; ActionID = '{00000000-0000-0000-0000-000000000121}' }
59$DisabledActions += [pscustomobject]@{ ActionName =  'Application manager user policy action'; ActionID = '{00000000-0000-0000-0000-000000000122}' }
60$DisabledActions += [pscustomobject]@{ ActionName =  'Application manager global evaluation action'; ActionID = '{00000000-0000-0000-0000-000000000123}' }
61$DisabledActions += [pscustomobject]@{ ActionName =  'Power management start summarizer'; ActionID = '{00000000-0000-0000-0000-000000000131}' }
62$DisabledActions += [pscustomobject]@{ ActionName =  'Endpoint deployment reevaluate'; ActionID = '{00000000-0000-0000-0000-000000000221}' }
63$DisabledActions += [pscustomobject]@{ ActionName =  'Endpoint AM policy reevaluate'; ActionID = '{00000000-0000-0000-0000-000000000222}' }
64$DisabledActions += [pscustomobject]@{ ActionName =  'External event detection'; ActionID = '{00000000-0000-0000-0000-000000000223}' }
65
66$TS = New-CMTaskSequence -CustomTaskSequence -Name "Run ConfigMgr Client Actions"
67 
68$EnabledGroup = New-CMTaskSequenceGroup -Name "Enabled Client Actions"
69Add-CMTaskSequenceStep -InsertStepStartIndex 0 -TaskSequenceName $TS.Name -Step $EnabledGroup
70
71$DisabledGroup = New-CMTaskSequenceGroup -Name "Disabled Client Actions" -Disable
72Add-CMTaskSequenceStep -InsertStepStartIndex 1 -TaskSequenceName $TS.Name -Step $DisabledGroup
73
74Function ProcessActions ($ClientActions, $Group)
75{
76    Foreach ($Action in $ClientActions)
77    {
78        #Format the sleep command for appending
79        $Sleep = If($SleepInSeconds -gt 0) {";Start-Sleep -seconds $($SleepInSeconds);"} else {$Sleep = ''}
80
81        #Format TS CommandLine
82        $cmdLine = [string]::Format("%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command `"Invoke-WmiMethod -Namespace root\CCM -Class SMS_Client -Name TriggerSchedule '{0}'{1}`"",$Action.ActionID, $Sleep)
83        Write-Host $cmdLine
84
85        #Create TS Step
86        $Step = New-CMTaskSequenceStepRunCommandLine -StepName "$($Action.ActionName)" -CommandLine "$($cmdLine)" -ContinueOnError
87
88        #Append Step to group
89        Set-CMTaskSequenceGroup -TaskSequenceName $TS.Name -StepName $Group.Name -AddStep $Step
90    }
91}
92
93ProcessActions $EnabledActions $EnabledGroup
94ProcessActions $DisabledActions $DisabledGroup

Results

Once you have run the script, you should end up with a Task Sequence like this:

And entries like this:

You should see entries in your smsts.log like this. Each step has Continue On Error turned on, so you will want to look at the logs to see if the steps are actually working.

 1Expand a string: WinPEandFullOS    TSManager   6/14/2018 10:31:22 PM   8664 (0x21D8)
 2Executing command line: smsswd.exe /run: %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command "Invoke-WmiMethod -Namespace root\CCM -Class SMS_Client -Name TriggerSchedule '{00000000-0000-0000-0000-000000000021}';sleep -seconds 120;"    TSManager   6/14/2018 10:31:22 PM   8664 (0x21D8)
 3[ smsswd.exe ]  InstallSoftware 6/14/2018 10:31:22 PM   9480 (0x2508)
 4PackageID = ''  InstallSoftware 6/14/2018 10:31:22 PM   9480 (0x2508)
 5BaseVar = '', ContinueOnError=''    InstallSoftware 6/14/2018 10:31:22 PM   9480 (0x2508)
 6ProgramName = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command "Invoke-WmiMethod -Namespace root\CCM -Class SMS_Client -Name TriggerSchedule '{00000000-0000-0000-0000-000000000021}';sleep -seconds 120;"'   InstallSoftware 6/14/2018 10:31:22 PM   9480 (0x2508)
 7SwdAction = '0001'  InstallSoftware 6/14/2018 10:31:22 PM   9480 (0x2508)
 8Command line for extension .exe is "%1" %*  InstallSoftware 6/14/2018 10:31:22 PM   9480 (0x2508)
 9Set command line: Run command line  InstallSoftware 6/14/2018 10:31:22 PM   9480 (0x2508)
10Working dir 'not set'   InstallSoftware 6/14/2018 10:31:22 PM   9480 (0x2508)
11Executing command line: Run command line    InstallSoftware 6/14/2018 10:31:22 PM   9480 (0x2508)
12InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
13InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
14__GENUS          : 1    InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
15__CLASS          : __PARAMETERS InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
16__SUPERCLASS     :  InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
17__DYNASTY        : __PARAMETERS InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
18__RELPATH        : __PARAMETERS InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
19__PROPERTY_COUNT : 1    InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
20__DERIVATION     : {}   InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
21__SERVER         : WS01 InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
22__NAMESPACE      : ROOT\ccm InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
23__PATH           : \\WS01\ROOT\ccm:__PARAMETERS InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
24ReturnValue      :  InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)
25PSComputerName   : WS01 InstallSoftware 6/14/2018 10:31:25 PM   9480 (0x2508)

Update 6/15/2018

I submitted a PR on GitHub to add all of the schedule codes to the SDK and it got MERGED!

https://github.com/MicrosoftDocs/SCCMdocs/pull/604#event-1683727219 https://docs.microsoft.com/sccm/develop/reference/core/clients/client-classes/triggerschedule-method-in-class-sms_client