System update management for Windows machines in an Active Directory (AD) environment is a critical task of an administrator. While managing the updates for a handful of machines is a fairly simple task, managing a many Windows machines and keeping track of their software updates can be cumbersome. Hence, administrators can make use of PowerShell to perform this task. Here are the scripts that can be used for deploying software updates for local and remote computers:
Deploying updates on a local computer
To deploy the updates on local computers, the following script can be used. This script will search for computers that do not have the updates installed, and then install the updates to those computers and reboot them. The script will also automatically accept any license agreements.
- Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot
Deploying updates on a remote computer
To deploy updates on remote computers, administrators must first create a variable with the names of the computers that are to be updated. Then, the following command can be typed to set the variable.
Note: $Node is the variable in this instance.
$Nodes = "computername01,computername02,....
Once done, administrators must enter the cmdlet that will import the PSWindowsUpdate module on the remote system, and then call on Microsoft Update to download and install any missing updates, and perform all the necessary actions similar to the one carried out by the script for updating local machines.
- Invoke-WUJob -ComputerName $Nodes -Script {ipmo PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot} -RunNow -Confirm:$false | Out-File "\\server\share\logs\$Nodes-$(Get-Date -f yyyy-MM-dd)-MSUpdates.log" -Force
Related Articles
Managing Microsoft 365 Compliance and Retention Policies with PowerShell
Microsoft 365 provides a range of compliance and retention features that enable organizations to meet their legal, regulatory, and business requirements. These features include compliance policies, retention policies, and retention labels. PowerShell ...
Managing mailboxes and their quota limits in Exchange
Management of the Microsoft Exchange environment in an organization is a comprehensive process. One of the various tasks is managing mailboxes, defining their quota limits, and identifying those that are over their given quota limit. This task can be ...
How to create and manage Microsoft 365 groups with PowerShell
Introduction: Microsoft 365 Groups is a collaboration feature that allows users to work together and share resources such as calendars, files, and email messages. Microsoft 365 Groups can be created and managed using the Microsoft 365 admin center, ...
Performing bulk operations in Microsoft 365 with PowerShell
Performing bulk operations in Microsoft 365 with PowerShell, such as bulk adding users or modifying attributes, can be a very useful and efficient way to manage your organization's users and resources. PowerShell is a powerful command-line tool that ...
How to monitor Microsoft 365 email and mailbox activity with PowerShell
Monitoring Microsoft 365 email and mailbox activity with PowerShell can be a crucial part of managing your organization's email security and compliance. With PowerShell, you can quickly and easily automate the process of monitoring email and mailbox ...