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 Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,580 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 112.4K Reputation points MVP
    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

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Andreas Baumgarten 112.4K Reputation points MVP
    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


  2. 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

    0 comments No comments

Your answer

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