Skip to content

Instantly share code, notes, and snippets.

@gwblok
Created January 13, 2020 15:28
Show Gist options
  • Save gwblok/4c7ef8fa122044e060bc991d77a597b6 to your computer and use it in GitHub Desktop.
Save gwblok/4c7ef8fa122044e060bc991d77a597b6 to your computer and use it in GitHub Desktop.
Reset-TaskSequence Function - Software Center "Installing" Spinning Wheel Reset
#Reset Task Squence - When Software Center shows "Installing" but nothing is really happening.
function Reset-TaskSequence
{
$OutputText = "Resetting CM Services to clear out TS - Takes about 3 minutes"
CMTraceLog -Message $OutputText -Type 2 -LogFile $LogFile
Set-Service smstsmgr -StartupType manual
Start-Service smstsmgr
start-sleep -Seconds 5
if (Get-CimInstance -Namespace root/ccm -ClassName SMS_MaintenanceTaskRequests )
{
Get-CimInstance -Namespace root/ccm -ClassName SMS_MaintenanceTaskRequests | Remove-CimInstance
}
if (Get-WmiObject -Namespace Root\CCM\SoftMgmtAgent -Class CCM_TSExecutionRequest)
{
Get-WmiObject -Namespace Root\CCM\SoftMgmtAgent -Class CCM_TSExecutionRequest | Remove-WmiObject
}
if ((Get-Process CcmExec -ea SilentlyContinue) -ne $Null) {Get-Process CcmExec | Stop-Process -Force}
#stop-service ccmexec
if ((Get-Process TSManager -ea SilentlyContinue) -ne $Null) {Get-Process TSManager| Stop-Process -Force}
#Stop-Service smstsmgr
Start-Sleep -Seconds 5
Restart-Service -Name CcmExec -Force
Start-Service ccmexec
Start-Sleep -Seconds 5
Start-Service smstsmgr
Start-Sleep -Seconds 20
if ((Get-Process TSManager -ea SilentlyContinue) -ne $Null) {Get-Process TSManager| Stop-Process -Force}
Start-Sleep -Seconds 20
if ((Get-Process CcmExec -ea SilentlyContinue) -ne $Null) {Get-Process CcmExec | Stop-Process -Force}
Start-Sleep -Seconds 15
Start-Service ccmexec
start-sleep -Seconds 60
Start-Process -FilePath C:\windows\ccm\CcmEval.exe
#Trigger Machine Policy Update
Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" |Out-Null
Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" |Out-Null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment