locked
powershell script for uninstalling scom agent RRS feed

  • Question

  • Hi

     

     Is there any "powershell" script to uninstall scom agents instead of manually uninstalling agents.

    Thursday, October 13, 2011 7:24 AM

Answers

  • hey dktoa.. do u have direct powershell script so that i can uninstall my 1300 servers in one go..

    I have a slow but automated method of doing this. See below

    1. Copy all your servers (netbios computername) into a text file
    2. Then run the following commands in OpsMgr powershell
    3. $list = get-content C:\TextFileYouCreatedAbove.txt
    4. $agents = foreach($agent in $list){get-agent | where{$_.ComputerName -eq $agent}}
    5. uninstall-agent -agentmanagedcomputer $agents

    Like I said this will take a while but it will work (in your case probably over a day with 1300 servers).  Maybe the Powershell can be optimized a bit to cut down the time?

    Anyways the point is it will be automated and you will get confirmation on the completion status in the Task Status view in the console
    • Marked as answer by Vivian Xing Tuesday, October 25, 2011 8:53 AM
    Friday, October 14, 2011 2:06 PM

All replies

  • See of any of this will help you:
    http://www.bictt.com/blogs/bictt.php/2011/05/31/scom-trick-19-remove-agent

    They are not powershells, but if you have the scripts/commands right I am sure you can build something.


    Bob Cornelissen - BICTT (My BICTT Blog) - Microsoft Community Contributor 2011 Recipient
    • Proposed as answer by dktoa Thursday, October 13, 2011 7:33 AM
    Thursday, October 13, 2011 7:29 AM
  • Hi,

    Here is some more input: http://systemcentersupport.blogspot.com/2009/05/scom-administration-through-powershell.html


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Edited by dktoa Thursday, October 13, 2011 7:32 AM
    Thursday, October 13, 2011 7:32 AM
  • hey dktoa.. do u have direct powershell script so that i can uninstall my 1300 servers in one go..
    Friday, October 14, 2011 3:37 AM
  • hey dktoa.. do u have direct powershell script so that i can uninstall my 1300 servers in one go..

    I have a slow but automated method of doing this. See below

    1. Copy all your servers (netbios computername) into a text file
    2. Then run the following commands in OpsMgr powershell
    3. $list = get-content C:\TextFileYouCreatedAbove.txt
    4. $agents = foreach($agent in $list){get-agent | where{$_.ComputerName -eq $agent}}
    5. uninstall-agent -agentmanagedcomputer $agents

    Like I said this will take a while but it will work (in your case probably over a day with 1300 servers).  Maybe the Powershell can be optimized a bit to cut down the time?

    Anyways the point is it will be automated and you will get confirmation on the completion status in the Task Status view in the console
    • Marked as answer by Vivian Xing Tuesday, October 25, 2011 8:53 AM
    Friday, October 14, 2011 2:06 PM