BDC Hamburger Icon

Menu

Close
BDC Logo
Search Icon
Advertising Disclosure
Close
Advertising Disclosure

Business.com aims to help business owners make informed decisions to support and grow their companies. We research and recommend products and services suitable for various business types, investing thousands of hours each year in this process.

As a business, we need to generate revenue to sustain our content. We have financial relationships with some companies we cover, earning commissions when readers purchase from our partners or share information about their needs. These relationships do not dictate our advice and recommendations. Our editorial team independently evaluates and recommends products and services based on their research and expertise. Learn more about our process and partners here.

How to Build an Interactive Menu Inside a PowerShell Script

Make it easier for non-PowerShell users to navigate your scripts.

Mark Fairlie
Written by: Mark Fairlie, Senior AnalystUpdated Jan 09, 2025
Gretchen Grunburg,Senior Editor
Business.com earns commissions from some listed providers. Editorial Guidelines.
Table Of Contents Icon

Table of Contents

Open row

If you’re confident with coding, you may find it easier to install Windows patches with PowerShell than to use Microsoft’s system. With PowerShell, you can remotely manage updates across multiple devices and customize how the update process works on each, similar to how you can remotely invoke applications with PowerShell to enhance efficiency and control. In addition, you can check for, remove and hide updates without being physically at your computer. Here’s a look at how to install Windows patches with PowerShell for free.

Installing and getting to know PSWindowsUpdate

PSWindowsUpdate is a community PowerShell module available via the PowerShell Gallery. In your PowerShell session, run Install-Module PSWindowsUpdate to download and install the latest version. The download should be quick. Once it’s downloaded, the module’s commands will be available to you. To view all available commands, run Get-Command -Module PSWindowsUpdate, and you’ll notice that you can perform many tasks beyond installing patches.

William Mabotja, an Azure-certified senior software developer at Atlas Finance, advised launching PowerShell as an administrator and running Install-Module -Name PSWindowsUpdate. “This command fetches the module from the PowerShell Gallery, making it available for your use,” Mabotja explained. “After installation, import it with Import-Module PSWindowsUpdate. Following these steps ensures a secure and up-to-date system without unnecessary hassle.”

FYIDid you know
Keeping hardware and software patches up to date should be part of every business's cybersecurity plan.
PSWindowsUpdate
PSWindowsUpdate example code

Querying missing patches

Before installing patches, you must determine which patches are needed across your systems. The PSWindowsUpdate module provides a command called Get-WindowsUpdate that you can use to discover any missing patches. The Get-WindowsUpdate command supports querying the local computer or remote computers.

When you run this command, it returns a list of all the missing updates on whatever computer you target. Here’s an example:

PSWindowsUpdate missing info

Mabotja emphasized that PowerShell significantly enhances update management for businesses that handle multiple devices by providing a centralized, scriptable interface that simplifies the update process across various systems. “For example, administrators can efficiently manage updates on numerous virtual machines (VMs) or physical devices simultaneously, reducing the time and effort required for manual updates,” Mabotja explained.

TipBottom line
If you're interested in other remote management tasks, consider learning how to manage files over SFTP with PowerShell or sync folders with PowerShell for continuous file integrity checks.

Installing missing patches

Once you know what you’re missing, take that information and install the patches. Get-WindowsUpdate provides many different parameters to query and install updates; in fact, it would be ideal for an interactive menu written in PowerShell designed for noncoders. For example, if you want to install the list of patches provided with the Get-WUList cmdlet, take the next logical step and install them with the Get-WindowsUpdate cmdlet. [Read related article: Why Speaking in Jargon Doesn’t Make You Look Smarter]

Mabotja appreciates PowerShell’s flexibility. “Running PowerShell as ‘Run as Administrator’ gives you access to low-level file systems,” he noted. “This makes it easier to install updates that need elevated permissions. With PowerShell, you can automate and customize the update process, helping you create a more reliable and manageable Windows environment.”

A patch can be in several different states, such as available, downloaded and installed. Some patches need a reboot to complete an installation, while others don’t. The Get-WindowsUpdate command gives you the flexibility to choose which updates are installed.

For example, say you care only about installing the missing updates. In this case, you can tell Get-WindowsUpdate to install all missing patches, accept every one it finds and initiate a reboot if necessary.

PSWindowsUpdate installation

Or, you could be a little gentler and pick specific updates, using the KBArticleId parameter. The following command would install only that particular KB, and if the computer needed a reboot, it would let you know rather than automatically rebooting.

PSWindowsUpdate specific update
Did You Know?Did you know
You can keep a patch downloaded but not installed. Then, if you carry out planned maintenance on a regular basis, you can install all downloaded updates the same day.

Additional issues to consider

PowerShell offers powerful tools for update management. Consider the following additional issues to better understand the potential challenges and opportunities:

  • Script complexity: Writing and managing scripts can be challenging, especially if you’re unfamiliar with the syntax. You must also ensure compatibility between updates and existing systems. “When it comes to patching with PowerShell, a big challenge is the complexity of scripts,” Mabotja cautioned. “You should invest time in training and take advantage of community resources, like forums and script repositories, to build a library of reliable scripts. Testing those scripts in a controlled environment before rolling out patches across your organization can help reduce risks.”
  • Advanced techniques: For businesses looking to go further, Mabotja suggests exploring scheduled tasks and Azure Functions. These approaches let you automate checks and installations at specific times, thus helping to minimize disruption to your business. “The PSWindowsUpdate module gives you more control over updates,” Mabotja said. “By combining PowerShell with Azure Functions Core Tools, you can test and develop locally before deploying. This streamlines the update process and helps you work more efficiently.”
    • Scheduled tasks allow you to automate checks and installations at specific times. Doing so during downtime, for example, reduces business disruption.
    • Azure Functions enable you to perform update-related tasks over the internet, making them ideal for businesses that rely heavily on cloud infrastructure.
FYIDid you know
 If you're working with web services, you can use PowerShell to manage IIS application pools. This keeps your web applications and their dependencies updated and stable.

Bringing PSWindowsUpdate and PowerShell into your business

The PSWindowsUpdate module has many options and uses — too many to cover in one article. Download it and try it for yourself. Check out the extensive help documentation for each function if you’re unfamiliar with the syntax. 

If you have the patience to learn this module, you can build some advanced update management solutions. PowerShell is also a great way to perform other tasks more efficiently. For example, you can make a web scraping tool in PowerShell to download competitors’ prices.

Adam Bertram contributed to this article. 

Did you find this content helpful?
Verified CheckThank you for your feedback!
Mark Fairlie
Written by: Mark Fairlie, Senior Analyst
Mark Fairlie brings decades of expertise in telecommunications and telemarketing to the forefront as the former business owner of a direct marketing company. Also well-versed in a variety of other B2B topics, such as taxation, investments and cybersecurity, he now advises fellow entrepreneurs on the best business practices. At business.com, Fairlie covers a range of technology solutions, including CRM software, email and text message marketing services, fleet management services, call center software and more. With a background in advertising and sales, Fairlie made his mark as the former co-owner of Meridian Delta, which saw a successful transition of ownership in 2015. Through this journey, Fairlie gained invaluable hands-on experience in everything from founding a business to expanding and selling it. Since then, Fairlie has embarked on new ventures, launching a second marketing company and establishing a thriving sole proprietorship.
BDC Logo

Get Weekly 5-Minute Business Advice

B. newsletter is your digest of bite-sized news, thought & brand leadership, and entertainment. All in one email.

Back to top