Getting Started with PowerShell and PSWindowsUpdate: The Ultimate Tutorial

In this article, we will explore the features and benefits of PSWindowsUpdate and delve into how it can enhance your Windows update experience. Whether you are an IT professional responsible for managing a network of computers or an individual user looking for a more efficient way to handle updates, PSWindowsUpdate can become an indispensable tool in your toolkit.

How to install the PSWindowsUpdate Module?

To install the PSWindowsUpdate module, follow the steps below:

  • Press the Windows key on your keyboard, type “PowerShell,” and then click on “Windows PowerShell” to open the PowerShell console.
  • Before installing any module, ensure that the PowerShell execution policy allows script execution. To check the execution policy, type the following command and press Enter:
Get-ExecutionPolicy
Get-ExecutionPolicy

If the policy is set to “Restricted” or “AllSigned,” you may need to change it to “RemoteSigned” or “Unrestricted” to install the module. To change the execution policy, run PowerShell as an administrator and type:

Set-ExecutionPolicy RemoteSigned
image 95

Confirm the change by entering “Y” when prompted.

  • To install the PSWindowsUpdate module, use the following command and press Enter:
Install-Module -Name PSWindowsUpdate -Force
Install-Module -Name PSWindowsUpdate -Force

The -Force parameter ensures that the module is installed without requiring user confirmation.

  • After the installation is complete, verify that the module was installed successfully. Run the following command:
Get-Module -Name PSWindowsUpdate
Get-Module -Name PSWindowsUpdate

You should see information about the installed module, including the name, version, and author.

How to check for Available Windows Updates?

To check for available Windows updates using the PSWindowsUpdate module, follow these steps:

  • Press the Windows key on your keyboard, type “PowerShell,” and then click on “Windows PowerShell” to open the PowerShell console.
  • If you haven’t done so already, import the PSWindowsUpdate module by running the following command and pressing Enter:
Import-Module -Name PSWindowsUpdate
Import-Module -Name PSWindowsUpdate
  • To check for available Windows updates, use the following command and press Enter:
Get-WindowsUpdate

This cmdlet will query the Windows Update service on your system and retrieve information about available updates.

  • The command will display a list of available updates along with details such as the update title, description, and installation status. You can review this information to determine which updates you want to install.

PSWindowsUpdate provides various parameters and filters that you can use to customize the output and focus on specific updates.

Removing Specific Windows Updates

To exclude specific Windows updates from installing using the PSWindowsUpdate module, you can utilize the “Hide-WindowsUpdate” cmdlet. Follow the steps below:

  • Press the Windows key on your keyboard, type “PowerShell,” and then click on “Windows PowerShell” to open the PowerShell console.
  • If you haven’t already imported the PSWindowsUpdate module, run the following command and press Enter:
Import-Module -Name PSWindowsUpdate
  • To view the list of available Windows updates, you can use the “Get-WindowsUpdate” cmdlet. This step is optional but helpful for identifying the updates you want to exclude. Run the following command:
Get-WindowsUpdate

Review the list of updates and take note of the update(s) you wish to exclude.

  • To exclude specific Windows updates from installing, use the “Hide-WindowsUpdate” cmdlet followed by the update’s KB number(s). For example, if you want to exclude an update with the KB number “KB1234567”, run the following command:
Hide-WindowsUpdate -KBArticleID "KB1234567"
Hide-WindowsUpdate -KBArticleID "KB1234567"

If you have multiple updates to exclude, you can separate them with commas. For instance:

Hide-WindowsUpdate -KBArticleID "KB1234567", "KB9876543"
Hide-WindowsUpdate -KBArticleID "KB1234567", "KB9876543"
  • To confirm that the updates have been successfully excluded, you can use the “Get-WindowsUpdate” cmdlet again. This time, it will display the list of updates, but the excluded updates should no longer appear.

How to install Windows Updates?

Getting All Available Updates

To install Windows updates using the PSWindowsUpdate module, follow these steps:

  • Press the Windows key on your keyboard, type “PowerShell,” and then click on “Windows PowerShell” to open the PowerShell console.
  • If you haven’t already imported the PSWindowsUpdate module, run the following command and press Enter:
Import-Module -Name PSWindowsUpdate
  • To view the list of available Windows updates, use the following command and press Enter:
Get-WindowsUpdate

This command will display a list of available updates along with details such as the update title, description, and installation status. Review the list to determine which updates you want to install.

  • To install all available updates, run the following command and press Enter:
Install-WindowsUpdate -AcceptAll -AutoReboot
Install-WindowsUpdate -AcceptAll -AutoReboot

This command will initiate the installation of all available updates, accepting any prompts or confirmations automatically. The “-AutoReboot” parameter ensures that the system will reboot if necessary after the updates are installed.

How to Check the Windows Update History?

To check the Windows Update history using the PSWindowsUpdate module, follow these steps:

  • Press the Windows key on your keyboard, type “PowerShell,” and then click on “Windows PowerShell” to open the PowerShell console.
  • If you haven’t already imported the PSWindowsUpdate module, run the following command and press Enter:
Import-Module -Name PSWindowsUpdate
  • To view the Windows Update history, use the following command and press Enter:
Get-WindowsUpdateLog
Get-WindowsUpdateLog

This command will fetch the Windows Update log, which contains information about the updates that have been installed on your system.

  • The output of the command will display the update history, including details such as the update title, KB number, installation date and time, and installation result (success, failed, etc.). You can scroll through the log to view the complete update history.

How to Remove Existing Windows Updates?

To remove existing Windows updates using the PSWindowsUpdate module, follow these steps:

  • Press the Windows key on your keyboard, type “PowerShell,” and then click on “Windows PowerShell” to open the PowerShell console.
  • If you haven’t already imported the PSWindowsUpdate module, run the following command and press Enter:
Import-Module -Name PSWindowsUpdate
How to Remove Existing Windows Updates?
  • To view the list of installed Windows updates, use the following command and press Enter:
Get-WindowsUpdate -Installed

This command will display a list of installed updates along with details such as the update title, KB number, installation date, and status.

  • To remove a specific update, use the “Remove-WindowsUpdate” cmdlet followed by the KB number(s) of the updates you want to remove. For example, to remove an update with the KB number “KB1234567”, run the following command and press Enter:
Remove-WindowsUpdate -KBArticleID "KB1234567"
How to Remove Existing Windows Updates?

If you have multiple updates to remove, separate them with commas. For instance:

Remove-WindowsUpdate -KBArticleID "KB1234567", "KB9876543"
How to Remove Existing Windows Updates?
  • After running the removal command, you will be prompted to confirm the removal of each update. Press “Y” and Enter to proceed with the removal. Depending on the number of updates being removed, you may need to confirm multiple prompts.
  • During the removal process, the PowerShell console will display progress updates for each update being removed. Allow the process to complete.

In conclusion, the PSWindowsUpdate module is a valuable addition to any Windows user’s toolkit. It simplifies the update management process, enhances system security, and saves time and effort.

By harnessing the power of PowerShell, users can take control of their Windows update experience and ensure their systems are always equipped with the latest patches, bug fixes, and enhancements.

Meet the Author

Abdul Rahim has been working in Information Technology for over two decades. Learn how Abdul got his start as a Tech Blogger , and why he decided to start this Software blog. If you want to send Abdul a quick message, then visit his contact page here.