Overview
This post provides a PowerShell script that creates an SCCM package to remove the Cherwell Service Management software, ensuring a clean slate for system configuration. This script is useful for decommissioning Cherwell from systems as part of a migration or software upgrade process.
Instructions
- Copy the provided PowerShell script to a location on your SCCM server.
- Adjust the script variables such as
$SCCMServer
,$SiteCode
, and$PackageSourcePath
to fit your environment. - Run the script in PowerShell to create the SCCM package for the Cherwell Service Management uninstaller.
- Distribute the package to the appropriate distribution points within SCCM.
- Monitor the deployment to ensure that Cherwell Service Management is successfully uninstalled from all targeted systems.
What the Script Does
This PowerShell script automates the creation of an SCCM package that uninstalls Cherwell Service Management using the `msiexec` command. This ensures a complete removal of the software from the system, leaving it ready for new configurations or software installations.
PowerShell Script
# Define Variables $SCCMServer = "\\YourSCCMServer" $SiteCode = "YourSiteCode" $ScriptName = "Cherwell-Service-Management-Uninstaller" $ScriptDescription = "Removes the Cherwell Service Management software, ensuring a clean slate for system configuration." $PackageSourcePath = "C:\Scripts\$ScriptName" # Load SCCM PowerShell Module Import-Module "$($Env:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" -Force # Connect to the SCCM Site cd "$SiteCode`:" # Check if a package with the same name exists and delete it $ExistingPackages = Get-CMPackage -Name $ScriptName -ErrorAction SilentlyContinue if ($ExistingPackages) { foreach ($Package in $ExistingPackages) { Remove-CMPackage -Id $Package.PackageID -Force } } # Create the Package Source Directory if it does not exist if (!(Test-Path -Path $PackageSourcePath)) { New-Item -ItemType Directory -Path $PackageSourcePath -Force } # Create the PowerShell script $ScriptContent = @' # Removes the Cherwell Service Management software msiexec /q /x {04F73471-157F-4F63-A2AD-50C1BBEECD66} '@ $ScriptPath = "$PackageSourcePath\Cherwell-Service-Management-Uninstaller.ps1" Set-Content -Path $ScriptPath -Value $ScriptContent # Create the SCCM Package $Package = New-CMPackage ` -Name $ScriptName ` -Description $ScriptDescription ` -Path $PackageSourcePath # Create a Program for the Package $Program = New-CMProgram ` -PackageName $ScriptName ` -StandardProgramName $ScriptName ` -CommandLine "powershell.exe -ExecutionPolicy Bypass -File Cherwell-Service-Management-Uninstaller.ps1" ` -ProgramRunType "WhetherOrNotUserIsLoggedOn" # Distribute the Package to the Distribution Point but do not deploy Start-CMContentDistribution ` -PackageName $ScriptName ` -DistributionPointName "YourDistributionPointName"
Explanation
This script creates an SCCM package that uninstalls the Cherwell Service Management software, ensuring that it is completely removed from the system. This process is managed and distributed via SCCM for consistency across all targeted systems.
Tags:
#Cherwell #Uninstall #PowerShell #SCCM