0

Remotely Restart-SCCMSyncCycle Using Powershell

Remotely Restart SCCM Sync Cycle Using Powershell

There are times when an SCCM administrator would need to quickly restart a remote machine’s sync cycle in order to have it talk back to the SCCM server and get whatever update you’re trying to push out. While there are ways to do in the GUI, it can also become very useful to have this accomplished using Powershell. The best thing about the Restart-SCCMSyncCycle script is that you can dynamically add multiple computers either from the pipeline or an array variable. Here is the script to remotely Restart-SCCMSyncCycle using Powershell.

Restart-SCCMSyncCycle Powershell Script


Function Restart-SCCMSyncCycle {
<#
.Synopsis
    Remotely restarts sccm service cycles.


.DESCRIPTION
    This function restarts all sccm policies on a remote client so that the client can immediately get any pending software updates or inventory.


.NOTES   
    Name: Restart-SCCMSyncCycle
    Author: theSysadminChannel
    Version: 1
    DateCreated: 2017-02-09


.LINK 
    https://thesysadminchannel.com/remotely-restart-sccmsynccycle-using-powershell -


.PARAMETER ComputerName
    The computer to which connectivity will be checked


.EXAMPLE
    Restart-SCCMSyncCycle -Computername Pactest-1

    Description:
    Will restart all sccm services on a remote machine.

.EXAMPLE
    Restart-SCCMSyncCycle -ComputerName pactest-1, pactest-2, pactest-3

    Description:
    Will generate a list of installed programs on pactest-1, pactest-2 and pactest-3

#>


    [CmdletBinding()]
        param(
            [Parameter(
                ValueFromPipeline=$true,
                ValueFromPipelineByPropertyName=$true,
                Position=0)]
            [string[]] $ComputerName = $env:COMPUTERNAME

        )

    Foreach ($Computer in $ComputerName ) {
        try {

            Write-Host "====================================================================="
			Write-Output "$Computer : Machine Policy Evaluation Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" -ErrorAction Stop | select -ExpandProperty PSComputerName | Out-Null 


			Write-Output "$Computer : Application Deployment Evaluation Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000121}" | select -ExpandProperty PSComputerName | Out-Null


			Write-Output "$Computer : Discovery Data Collection Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000003}" | select -ExpandProperty PSComputerName | Out-Null


			Write-Output "$Computer : File Collection Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000010}" | select -ExpandProperty PSComputerName | Out-Null


			Write-Output "$Computer : Hardware Inventory Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000001}" | select -ExpandProperty PSComputerName | Out-Null


			Write-Output "$Computer : Machine Policy Retrieval Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" | select -ExpandProperty PSComputerName | Out-Null


			Write-Output "$Computer : Software Inventory Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000002}" | select -ExpandProperty PSComputerName | Out-Null


			Write-Output "$Computer : Software Metering Usage Report Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000031}" | select -ExpandProperty PSComputerName | Out-Null


			Write-Output "$Computer : Software Update Deployment Evaluation Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000114}" | select -ExpandProperty PSComputerName | Out-Null


			#Write-Output "$Computer : Software Update Scan Cycle"
			#Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}" | select -ExpandProperty PSComputerName | Out-Null


			Write-Output "$Computer : State Message Refresh"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000111}" | select -ExpandProperty PSComputerName | Out-Null


			#Write-Output "$Computer : User Policy Retrieval Cycle"
			#Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000026}" | select -ExpandProperty PSComputerName | Out-Null


			#Write-Output "$Computer : User Policy Evaluation Cycle"
			#Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000027}" | select -ExpandProperty PSComputerName | Out-Null


			Write-Output "$Computer : Windows Installers Source List Update Cycle"
			Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000032}" | select -ExpandProperty PSComputerName | Out-Null

			sleep 1
        }

        catch {
            Write-Host $Computer.toUpper() "is not online" -ForegroundColor:Red
            Write-Host
            Write-Host

        }
    }
}

The output when ran on multiple computers looks something like the image below.
Restart-SCCMSyncCycle -ComputerName
 

Hopefully you can find some use out of this Restart-SCCMSyncCycle script to manage your SCCM clients. I know during my time as an SCCM administrator it has helped me tons.

Also don’t forget to check out our SCCM Playlist on YouTube for more SCCM tips and tools.

5/5 - (9 votes)

Paul Contreras

Hi, my name is Paul and I am a Sysadmin who enjoys working on various technologies from Microsoft, VMWare, Cisco and many others. Join me as I document my trials and tribulations of the daily grind of System Administration.

Leave a Reply

Your email address will not be published.