Created
September 15, 2018 18:58
-
-
Save shinish/ac92bd2c863bf840ea581cc07672a13e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$VerbosePreference = "Continue" | |
$Computers = Get-Content "c:\scripts\Serverlist.txt" | |
foreach ($ComputerName in $Computers){ | |
Invoke-Command -ComputerName $ComputerName -ScriptBlock { | |
if (Test-Path 'C:\windows\CCM'){ | |
Write-Output "$env:ComputerName : Script is Running" | |
get-service ccmexec -ea SilentlyContinue | | |
Stop-Service -Force -Verbose | |
Remove-Item -Path "$($Env:WinDir)\CCM" -Force -Confirm:$false -Verbose | |
Remove-Item -Path "$($Env:WinDir)\CCMSetup" -Force -Confirm:$false -Verbose | |
Remove-Item -Path "$($Env:WinDir)\CCMCache" -Force -Confirm:$false -Verbose | |
Remove-Item -Path "$($Env:WinDir)\smscfg.ini" -Force -Confirm:$false -Verbose | |
Remove-Item -Path 'HKLM:\Software\Microsoft\SystemCertificates\SMS\Certificates\*' -Force -Confirm:$false -Verbose | |
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\CCM' -Force -Recurse -Verbose | |
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\CCM' -Force -Recurse -Confirm:$false -Verbose | |
Remove-Item -Path 'HKLM:\SOFTWARE\Microsoft\SMS' -Force -Recurse -Confirm:$false -Verbose | |
Remove-Item -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\SMS' -Force -Recurse -Confirm:$false -Verbose | |
Remove-Item -Path 'HKLM:\Software\Microsoft\CCMSetup' -Force -Recurse -Confirm:$false -Verbose | |
Remove-Item -Path 'HKLM:\Software\Wow6432Node\Microsoft\CCMSetup' -Force -Confirm:$false -Recurse -Verbose | |
Remove-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\CcmExec' -Force -Recurse -Confirm:$false -Verbose | |
Get-CimInstance -query "Select * From __Namespace Where Name='CCM'" -Namespace "root" | | |
Remove-CimInstance -Verbose -Confirm:$false | |
Get-CimInstance -query "Select * From __Namespace Where Name='CCMVDI'" -Namespace "root" | | |
Remove-CimInstance -Verbose -Confirm:$false | |
Get-CimInstance -query "Select * From __Namespace Where Name='SmsDm'" -Namespace "root" | | |
Remove-CimInstance -Verbose -Confirm:$false | |
Get-CimInstance -query "Select * From __Namespace Where Name='sms'" -Namespace "root\cimv2" | | |
Remove-CimInstance -Verbose -Confirm:$false | |
Write-Output "$env:ComputerName : Script Ended" | |
} | |
else { | |
Write-Warning " $env:ComputerName : Setup files not found, Verify the client installation" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment