Windows Update with PowerShell – Easy Windows Patching
Patch Windows 10,11 - Windows Server 2016/19/22/25
Table of Contents
Install Windows Update With PowerShell
If you want to know about Windows update with PowerShell, this article will guide you step by step to patch your Windows server easily.
Here we are using Windows Server 2025 Windows Insider to demonstrate the steps.
Updating or patching Windows Server 2025 with PowerShell can simplify the Administrator life.
Therefore, it saves you time and gives you more accuracy on the update installation.
You must run the PowerShell in an elevated mode to smooth the process.
As a fresh Windows server, if you run the cmdlet “Get-WindowsUpdate”, it will not work.
You have to install the PSWindowsUpdate module first so that you can patch your Windows Server 2025.
Not only the Windows Server can be updated via PowerShell.
However, you can also patch your Windows 10, Windows 11, and Windows Server 2016/19/22.
Things to know before Updating Your Windows
As I already mentioned, you will get an error if you directly run the following cmdlet
Get-WindowsUpdate
It will throw an error the term ‘Get-WindowsUpdate’ is not recognized as the name of a cmdlet, function, script file, or operable program.
So, to fix this issue we have to first install the PSWindowsUpdate Module by running the following cmdlet.
Install-Module PSWindowsUpdate
It will prompt you Nuget provider is required to continue and Press Y to accept it.
Once you press the Y to accept it, it will give you a warning to install the repository from PSGallery.
Press the Y again will accept the terms and it will install the Nuget provider.
How to Update Windows with Powershell
After completing the above steps, we are good to run the Get-WindowsUpdate cmdlet
If we see our Windows update in a graphical view, we have an update regarding Windows 11 insider preview.
So, let’s see what we have in our PowerShell if we run the following cmdlet.
Get-WindowsUpdate
We have two updates KB5040176 and KB5043465 for Azure connected Machine Agent.
Now we want to install both of the updates and auto reboot the system, so we will run the following cmdlet
Get-WindowsUpdate -AcceptAll -Install –AutoReboot
Note: If you do not want to reboot, you can just simply run the cmdlet Install-WindowsUpdate and press Y to accept the terms.
Here we are going to run the cmdlet that will reboot the system.
Now you can see it is downloading and installing the Windows Updates.
You can see the screen below, it downloaded the updates and KB5040176 is installed and KB5043465 is in under process of installation.
Once it is complete, the computer will reboot automatically.
Let’s see the update status now.
Now if we check our Windows update screen, you can see in the image below that, our 2 updates were successfully installed via the PowerShell cmdlet.
We have successfully patched our Windows Server 2025 by using PowerShell.
Other Considerations While Patching Your Windows Server
Therefore, if you have multiple updates displayed on the screen for available updates on your computer and you only want to update a particular update.
In that case, you can run the following cmdlet.
Get-WindowsUpdate -Install -KBArticleID 'KB5043465'
The above cmdlet will only install this particular KBArticleID Update.
Other Cmdlet in PSWindowsUpdate Module
There are several other cmdlets available in the PSWindowsUpdate Module
To know the other available cmdlets in PSWindowsUpdate Module run the following cmdlet
Get-command-Module PSWindowsUPdate
You will see the below image for other available cmdlets in the PSWindowsUpdate Module
Therefore, for example, to check the Windows Update history you can run the cmdlet Get-WUHistory
However, you can use a PowerShell Script to check the last update Date & Time as well
In our case, we have multiple computers in our network and we want to check the last update on all 5 computers.
We ran a script and found out the last updated date and time.
The below screen shows the last update date and time for our computer available on the network and joined in the domain.
Conclusion
In this article, we learned how we can patch our Windows and Windows servers with the help of PowerShell to make the administrative task easy.
However, we also explored the other considerations while doing Windows updates with PowerShell.
Finally, we ran the Windows PowerShell script to check the last update date and time on our domain-joined computers available in our network.
I hope this article will help you patch your Windows 10,11, and Windows server 2016/19/22/25 in an easy way.
In case of any issue with this article, you can feel free to Contact Us
To see it in action, watch the video to update your Windows Server 2025 using PowerShell