Kae Travis

Trigger SCCM Client Actions Remotely using PowerShell

This is a simple PowerShell script that can be used to trigger SCCM client actions remotely using PowerShell.

It only currently supports three client actions for simplicity’s sake (MachinePolicy, DiscoveryData, SoftwareInventory) but you can add more as specified here.

Usage is simple – just pass in an array of machine names that you want to trigger client action on, and the client actions that you want to trigger. In this example, we want to trigger the client actions ‘MachinePolicy’ and ‘DiscoveryData’ on machines ‘Alkane01′ and Alkane02’

$machines = @("Alkane01","Alkane02") 
$schedules = @("MachinePolicy","DiscoveryData") 
Trigger-Schedule -machines $machines -schedules $schedules

And here is the script:

  function Trigger-Schedule {
[CmdletBinding()] 
param 
( 
[Parameter(Mandatory = $true)] 
[String[]]$machines, 
[Parameter(Mandatory = $true)] 
[ValidateSet('MachinePolicy', 
'DiscoveryData',           
'SoftwareInventory')] 
[String[]]$schedules
) 
$supportedSchedules = @{ 
"MachinePolicy" = "{00000000-0000-0000-0000-000000000021}"; 
"DiscoveryData" = "{00000000-0000-0000-0000-000000000003}"; 
"SoftwareInventory" = "{00000000-0000-0000-0000-000000000002}"; 
} 
foreach ($machine in $machines) 
{ 
If (Test-Connection -ComputerName $machine -Count 1 -Quiet) 
{ 
foreach ($schedule in $schedules) 
{
try { 
write-host "Invoking $schedule on $machine" 
$scheduleGUID = $supportedSchedules[$schedule]                     
Invoke-WMIMethod -ComputerName $machine -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule $scheduleGUID
} catch { 
write-host $_.Exception.Message 
} 
} 
} else { 
write-host "Cannot ping $machine" 
} 
} 
}
Trigger SCCM Client Actions Remotely using PowerShell
Trigger SCCM Client Actions Remotely using PowerShell

Leave a Reply