It's always a bad idea to send out a package on a Friday afternoon - and hope for the best - because the longest afternoons are usually the Friday ones, they can last several days when you need to remediate a couple of 1000 hosts where application installations got corrupted because of your Friday SCCM package. What you want, before hitting the full list of 1000s of servers with a package is to send it out to a couple and quickly see the result. However, if you send out a package it can take up to an hour to see the results in SCCM - depending on your SCCM site settings... How can you make it quicker? Invoke a client action on each host called "Machine Policy Retrieval & Evaluation Cycle".
![]() |
| SCCM Client Actions |
Background:
SCCM client has several agents and those can perform actions, such as downloading policies and packages from the server, perform software or hardware inventories...etc. Because all these agents are built on WMI, you can invoke actions by creating WMI instances of specific WMI classes on the remote machine.
OK, so the idea is there. When you want to break.. khm deploy something on many, many servers, you just pick about 50 or maybe 100 firts, send out the package and then... and this is where powershell comes in: run the following script to invoke the MAchine Policy Retrieval & Evaluation Cycle which will make the client download the package and run it + report back to the SCCM server.
$hostlist = @($Input)
if($($hostlist.length) -gt 0){
foreach ($srv in $hostlist) {
# Binding \\$srv\root\ccm:SMS_Client
$SMSCli = [wmiclass] "\\$srv\root\ccm:SMS_Client"
if($SMSCli){
#Invoking $actionName
$check = $SMSCli.RequestMachinePolicy()
$check = $SMSCli.EvaluateMachinePolicy()
}
else{
write-host "$srv, Could not bind WMI class SMS_Client"
}
}
}
Save it as a something.ps1 file and use it like this:
PS C:\> gc hostlist.txt | something.ps1
Clipboard friendly code:
$hostlist = @($Input)
if($($hostlist.length) -gt 0){
foreach ($srv in $hostlist) {
# Binding \\$srv\root\ccm:SMS_Client
$SMSCli = [wmiclass] "\\$srv\root\ccm:SMS_Client"
if($SMSCli){
#Invoking $actionName
$check = $SMSCli.RequestMachinePolicy()
$check = $SMSCli.EvaluateMachinePolicy()
}
else{
write-host "$srv, Could not bind WMI class SMS_Client"
}
}
}
