0

So my goal here is to run commands like get-adcomputer | Install-WindowsUpdate -AcceptAll -AutoReboot

I want to get all of my AD computers and pipe the ComputerName to the ComputerName property in Install-WindowsUpdate. I tried a @foreach statement but it takes forever to run because it does them one at a time. I'm looking for it to do multiple computers at once.

Any ideas?

  • [1] that cmdlet is not a standard item. what module did you install? ///// [2] if the module is `PSWindowsUpdate` from the powershellgallery site, then the cmdlet has been remapped >>> `New-Alias Install-WindowsUpdate Get-WindowsUpdate`. if that is so ... then that command DOES NOT accept pipeline input. ///// [3] have you tried using `Invoke-Command` to run things in parallel? – Lee_Dailey Jan 05 '21 at 22:58
  • it is PSWindowsUpdate. Do you have an example of using the Invoke-Command to run Install-WindowsUpdate using the computernames within the Get-ADcomputer output? – Jarrod L. J. Gibson Jan 06 '21 at 14:45
  • i don't have anything other than my one home computer, so i can't test what you are working with. [*sigh ...*] ///// if you `Read The Friendly Manual` [*grin*], the instructions seem pretty clear on how to use the `I-C` cmdlet. the main gotcha is variable scope - and the easiest solution to that is the `$Using:` scope modifier. if that doesn't help, then i recommend you either do a search on examples for using `I-C`, OR that you try to find a support forum for that module. ///// good luck! [*grin*] – Lee_Dailey Jan 06 '21 at 19:45

1 Answers1

0

So what I ended up doing was creating a computers variable from Get-ADcomputer. I piped a select statement to grab the property "Name" and that did the trick. I then plugged the variable into the command:

$computer = Get-ADComputer -SearchBase "OU=Computers,DC=my,DC=domain,DC=com" -Filter 'Name -like "*vdi*"' | Select -ExpandProperty name
Get-windowsupdate -ComputerName $computer -AcceptAll -Install -AutoReboot

To make this work, you have to make sure all of the computers have PSWindowsUpdate installed, Enable-WURemoting and set-executionpolicy unrestricted, which i'm not thrilled about.

Hope this helps others out there.