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?

3
  • [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 5, 2021 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? Jan 6, 2021 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 6, 2021 at 19:45

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .