Share via

Updating Workstations via PowerShell

SourSnacks 101 Reputation points
2021-05-24T18:36:00.56+00:00

Looking for a script that can search for then install any pending updates or just install any pending updates on workstations running windows 10 within a specific OU in AD. We're a small shop that doesn't utilize WSUS, but we have approximately 100 workstations that we manage. I was able to run basic commands on my workstation like Get-WindowsUpdate to see what I have pending then Install-WindowsUpdate to actually install them.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

  1. Andreas Baumgarten 131.7K Reputation points MVP Volunteer Moderator
    2021-05-24T21:33:52.663+00:00

    Hi @SourSnacks ,

    I am not 100% sure if it's possible to Windows 10 Feature Updates this way.
    Maybe this post helps for testing:
    https://win10.guru/use-powershell-to-update-and-upgrade-windows-10/

    To get the computers from OU in AD please try this:

    $computers = Get-ADComputer -Filter * -SearchBase "OU=OUwithComputers, DC=TEST, DC=LOCAL"  
    Invoke-WUJob -ComputerName $computers -Script {import-module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot} -RunNow -Confirm:$false   
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    Was this answer helpful?

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Hanjgikar, Alhaj 6 Reputation points
    2022-12-15T07:29:15.63+00:00

    hello All,

    below is the script that will provide all the pending / unapplied patches list

    $UpdateSession = New-Object -ComObject Microsoft.Update.Session
    $UpdateSearcher = $UpdateSession.CreateupdateSearcher()
    $Updates = @($UpdateSearcher.Search("IsHidden=0 and IsInstalled=0").Updates)
    $Updates | Select-Object Title

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Alhaj

    Was this answer helpful?

    0 comments No comments

  2. Andreas Baumgarten 131.7K Reputation points MVP Volunteer Moderator
    2021-05-24T18:53:02.923+00:00

    Hi @SourSnacks ,

    maybe this is helpful to get started:

    $computers = "computer01,computer02"  
    Invoke-WUJob -ComputerName $computers -Script {import-module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot} -RunNow -Confirm:$false   
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.