How to Delete an Operations Manager 2007 Managed Object from a Management Group using PowerShell (Updated PS script which works on PowerShell V2 and above)

How to Delete an Operations Manager 2007 Managed Object from a Management Group using PowerShell (Updated PS script which works on PowerShell V2 and above)

  • Comments 6
  • Likes

(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 \DeleteAgent.ps1  satyamachine.vel.net

 

 

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 Set-Unrestricted 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 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell registry key to the desired script execution mode.

Satya Vel | Program Manager | System Center |

 

Attachment: DeleteAgent.ps1.zip
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • <p>great an article, I'm very thank you, I think really usefull, I'm following &nbsp;comments, thanks</p>

  • <p>What if we used the uninstall option for the Agent from the console successful, then formatted the machine. What is the best way to purge it from Operations Manager at that point since it now shows up as grey with an overall healthy checkmark and no checkmark at all in the agent area as it was no longer agent managed? Thanks!</p>

  • <p>I am a rookie admin with power shell. When you said &quot;you need to specify the FQDN of the machine name after you run the script \DeleteAgent.ps1 machine FQDN&quot; how do i run this? I have tried to run this script directly or by copying into the powershell script. Thanks.</p>

  • <p>[url=<a rel="nofollow" target="_new" href="http://fluoxetine.wikispaces.com/">http://fluoxetine.wikispaces.com/</a>]fluoxetine 30 </p> <p>[/url]</p>

  • <p>Same question as bday. We successfully removed the agent via the console Uninstall command before decommissioning the server.</p> <p>However the machine(s) remain in the Monitoring pane/Computer State view as grey 'lingering' objects with no option to delete them.</p>

  • <p>Hi all! </p> <p>Nice site! </p> <p>G'night</p>