Hey! I work with a company, that the customers, come and go pretty much. So sometimes they gonna install the CM-agent and sometimes some customers leaves. Then we need to uninstall the CM-Agent remotely of course! God forbidden manually!
You need
* Server 2008 R2 or above
* Windows 7 With PowerShell 3.0 installed or above
* CM2012
1. Create a Collection.
2. Create a Configuration item
2.1 Then the “Setting step”, Modify like below
2.2 Choose Script like this:
2.3 Edit “Discovery Script”: Then you post in this:
function Get-ccmexec-service { [CmdletBinding()] param () Begin { } Process { Try { Get-Service -Name CcmExec | ForEach-Object { If($_.Name -eq "none") { $State = 0 } ElseIf($_.Name -eq "ccmexec") { $State = 1} } } catch { # Error handling } $state } End { } } Get-ccmexec-service
2.4 Then “Remediation Script” you post in this:
C:\Windows\ccmsetup\ccmsetup.exe /uninstall
2.5 Then in the Compliance Rules tab, Add this:
2.4. The Finish the Configuration Item Wizard.
3. Create a Baseline to this, And put the deployment to your Collection.
4. And you are Done
Good Luck
/Pontus