(Updated PS script below which works on PowerShell V2 and above)
We have had some customers ask us if there is a way to remove an agent managed computer using PowerShell from OpsMgr 2007 after the agent managed computer has been turned off. The scenario is that the machine that has an agent installed on it gets de-commissioned for some reason and now the user would like to get rid of all the traces left by that particular agent machine using PowerShell. The
attached PowerShell script
should take care of this for you. Note: This script is not officially supported by the product team and used only when needed.
You need to specify the FQDN of the machine name after you run the script
Why am I am not able to execute custom scripts in PowerShell?
On some PowerShell installs you will not be able to run this script because PowerShell is probably running on “Restricted” mode which means that the scripts need to be signed. You can bypass this by doing the following.
To change the script execution mode from the default RemoteSigned script execution mode, use the
cmdlet in the OpsMgr 2007 Command Shell. The OpsMgr 2007 Command Shell recognizes the change to the policy immediately.
Users that want to set a consistent script execution mode for all computers that are running the OpsMgr 2007 Command Shell should apply the script execution mode setting by using an Active Directory group policy. You configure the Active Directory group policy to set the ExecutionPolicy value located under the
registry key to the desired script execution mode.