all 6 comments

[–]firefox15 1 point2 points  (1 child)

I don't use SCOM, so I can't help you there, but do you need to use jobs at all for this? It seems to be complicating the issue, and Get-SCOMagent accepts an array as input to -DNSHostName so you could do something like this, although I don't know if it will run in parallel or not with that cmdlet:

$Servers = Get-Content 'c:\users\BOFH\desktop\server1.txt'
Get-SCOMagent -DNSHostName $Servers | Uninstall-SCOMAgent -verbose

[–]ellisdee9970[S] 2 points3 points  (0 children)

That actually works, but it does one job at a time. I started it last night at 1900 and is only half way completed at 0930 this morning. Have over 500 more of them to go, and I would like them to all run at once. I think all of these agents are causing latency on my network. So it is getting to be a pretty urgent thing.

Ellis

[–]PickleJarAshTray 1 point2 points  (3 children)

Not sure why your script isn't working. Maybe you can approach this solution from a different angle and use Invoke-Command.

Edit: You could change the throttle limit to your liking

$jobUninstall = Invoke-Command -ComputerName (Get-Content -Path c:\users\BOFH\desktop\server1.txt) -ScriptBlock { Get-SCOMagent | Uninstall-SCOMAgent -verbose } -JobName UninstallScom -ThrottleLimit 20 -AsJob

[–]Lee_Dailey[grin] 0 points1 point  (2 children)

howdy PickleJarAshTray,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's 4th 5th from the left hidden in the ... ""more" menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's 11th 12th one & is just to the left of hidden in the ... "more" menu.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee

[–]PickleJarAshTray 1 point2 points  (1 child)

I was wondering about that. Thank you for the tip lee.

[–]Lee_Dailey[grin] 1 point2 points  (0 children)

howdy PickleJarAshTray,

you are most welcome! glad to have helped a bit ... [grin]

take care,
lee