Using Powershell - How to Uninstall the Configuration Manager Client (SSCM)

Version:System Center Configuration Manager 2007 SP2

As you know you can uninstall the Configuration Manager 2007 client software from a computer by using CCMSetup.exe with the /Uninstall switch and if you don't want to reinvent the wheel use below script

Using powershell you can do it for single or multiple servers.

Check if path is accessible or not

Example

$Server = "DEVAzureServer"
Test-Path -Path "\\$Server\D$\windows\ccmsetup\ccmsetup.exe"

Copy and Try it

Output should be true

Using Invoke-Command you can Uninstall sscm

Example

$cmds = { C:\windows\ccmsetup\ccmsetup.exe /uninstall }
Invoke-Command -Scriptblock $cmds

Copy and Try it

For mutiple servers

Example

$listOfServers = @("Server1", "Server2", "Server3" )
$cmds = { C:\windows\ccmsetup\ccmsetup.exe /uninstall }
 
#traverse through list of servers
Foreach($svr in $listOfServers)
{
    $svr = $svr.Trim()
    Write-Host "Processing $svr"
  
    #Check if server exist
    $DNSHostByName = ([System.Net.Dns]::GetHostByName(("$svr")))
  
    If(!$DNSHostByName)
    {
        Write-Warning "$svr does not exist"
    }
    Else
    {
        Invoke-Command -Scriptblock $cmds -ComputerName $svr
    }
}

Copy and Try it