If you are looking for a script to initiate SCCM client actions on local or multiple remote computers then you are at right place, here is the simple script that can trigger the SCCM client actions.
SCCM Configuration manger client trigger action list, important triggers most administrators use on a daily basis, same we will in use our Powershell script.
Hardware Inventory Cycle “{00000000-0000-0000-0000-000000000001}”
Software Inventory Cycle “{00000000-0000-0000-0000-000000000002}”
Software Metering Usage ReportCycle “{00000000-0000-0000-0000-000000000031}”
User Policy Retrieval Cycle “{00000000-0000-0000-0000-000000000026}”
File Collection Cycle “{00000000-0000-0000-0000-000000000010}”
Software Update Scan Cycle “{00000000-0000-0000-0000-000000000113}”Application Deployment Evaluation Cycle “{00000000-0000-0000-0000-000000000121}”
Discovery Data Collection Cycle “{00000000-0000-0000-0000-000000000003}”
Powershell Script for SCCM Client Actions
We need to create a file for storing all the servers or multiple machines list, I named it as Allservers.txt for and saved it in my local machine c:\temp\Allservers.txt
$Allserers = get-content -path "C:\temp\Allservers.txt"
foreach ($server in $allservers)
{
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000001}"
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000002}"
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000031}"
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000026}"
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000010}"
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}"
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000121}"
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000003}"
}
# End of SCript
One can remove the triggers which are not needed and execute the script, it works too. Now we are going to create a function to use the script whenever we need it.
In this function also I’m using same variable as $Allservers to store computer names.
#SCCM Client Actions on local or multiple remote computers
function SCCM-Client-Action
{
PARAM(
[Parameter(Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True)]
[string[]]$ComputerName = $env:COMPUTERNAME,
[Parameter(Mandatory=$True)] [ValidateSet('SoftwareInv','HardwareInv','UpdateScan','UserPolicy','DiscoveryInv','FileCollect','MachinePol','SoftwareMetr')]
[string]$Action
)
#$SCCM Actions siwtches
SWITCH ($action) {
'SoftwareInv' {$_action = "{00000000-0000-0000-0000-000000000002}"}
'HardwareInv' {$_action = "{00000000-0000-0000-0000-000000000001}"}
'UpdateScan' {$_action = "{00000000-0000-0000-0000-000000000113}"}
'UserPolicy' {$_action = "{00000000-0000-0000-0000-000000000027}"}
'FileCollect' {$_action = "{00000000-0000-0000-0000-000000000010}"}
'MachinePol' {$_action = "{00000000-0000-0000-0000-000000000021}"}
'SoftwareMetr' {$_action = "{00000000-0000-0000-0000-000000000031}"}
}
FOREACH ($server in $Allservers)
{
if ($PSCmdlet.ShouldProcess("$action $server")) {
Invoke-WmiMethod -ComputerName $server -Namespace root\CCM -Class SMS_Client -Name TriggerSchedule -ArgumentList "$_action"
}
}
}
Thank you for reading this article, if you have any questions please let us know.
Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.
Leave a Reply Cancel reply