Hello folks, I have a very simple script I use to bulk uninstall SCOM agents from a text file:
$path=d:\temp\serverlist.txt
$list=get-content$path
$cred=Get-Credential
foreach($name in$list)
{
$agents=get-scomagent
uninstall-scomagent-agent$agents-ActionAccount$cred
}
When I use this script it uninstalls the SCOM agent from a server one at a time. When I do this from the SCOM console it performs the uninstallation on all of the systems at the same time.
Doing it one at a time via the script takes a very long time. I would like the script to perform the same way it does when you use the SCOM GUI to perform this task.
Now, I've heard a little about multi-threading or parallel processing in the newer versions of Powershell but I'm not sure if that would be the solution here? When the agent uninstallation task is performed via the SCOM console I see one task created. I don't want to see multiple tasks created in SCOM for each system via multiple Powershell workflows. I just want to see one task.
I'm hoping to get some advice here on the best way to optimize this script? Thx!
-Wilson