Dump Servers in SCOM2007R2 and Remove Agent

When migrating from SCOM2007R2 to SCOM2012 you need to bulk dump the servers in SCOM2007 and remove the agent. It’s much work to do this every single server, you’ll need to automate this working. Here’s a little how-to do this.

PS>get-agent|export-csv -notype c:\scomagents.csv
  • Now pick all the servers you need to remove the agent from and put them in a servers.txt file
  • Download SysInternals and put PsExec in the executable path
  • Make an executable .BAT file with the following (and name it SCOM2007R2_removal.bat):
msiexec /x {25097770-2B1F-49F6-AB9D-1C708B96262A} /qn /norestart /l*vx %temp%\RemoveAgent.log
  • Start an elevated CMD by running this:
echo password | runas /env /netonly /user:DOMAIN\domainadmin "psexec.exe cmd.exe"
  • Run the removal by the following command (make sure you have the correct permissions and the files are readable by all the servers):
for /f %a in (\\server\c$\servers.txt) do psexec -u DOMAIN\domainadmin -p PA$$W0RD \\%a \\server\c$\SCOM2007R2_removal.bat
  • Agents will now be removed for all the severs in the servers.txt file