Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Managing updates on Windows systems is crucial for maintaining security and performance. One of the most powerful tools for handling updates is PowerShell, specifically using the Get-WindowsUpdate
cmdlet. This article will guide you through the process of using Get-WindowsUpdate
to check for, download, and install updates on Windows.
Get-WindowsUpdate
is a cmdlet provided by the Windows Update PowerShell Module (PSWindowsUpdate). This module allows administrators to manage Windows updates from the command line, offering greater flexibility and automation capabilities compared to the traditional GUI-based Windows Update interface.
Before you can use Get-WindowsUpdate
, you need to install the PSWindowsUpdate module. Here’s how you can do it:
Open PowerShell as an Administrator.
Run the following command to install the module from the PowerShell Gallery:
Install-Module -Name PSWindowsUpdate -Force -Scope CurrentUser
Import the module into your PowerShell session:
Import-Module PSWindowsUpdate
To check for available updates, you can use the Get-WindowsUpdate
cmdlet:
Get-WindowsUpdate
This command will list all available updates for your system.
To download and install updates, use the Install-WindowsUpdate
cmdlet. You can specify which updates to install or choose to install all available updates.
To install all available updates:
Install-WindowsUpdate -AcceptAll -AutoReboot
-AcceptAll
: Automatically accept all updates.-AutoReboot
: Automatically reboot the system if required after installation.To install specific updates, you can use the -KBArticleID
parameter:
Install-WindowsUpdate -KBArticleID KB5005565 -AcceptAll -AutoReboot
You can schedule updates to run at a specific time using Task Scheduler and PowerShell. Here’s an example of how to create a scheduled task to run the update script daily at 3 AM:
Create a PowerShell script (e.g., UpdateScript.ps1
) with the following content:
Import-Module PSWindowsUpdate
Install-WindowsUpdate -AcceptAll -AutoReboot
Open Task Scheduler and create a new task.
Configure the task to run daily at 3 AM.
Set the action to start a program and specify powershell.exe
as the program.
Add the following arguments to run your script:
-File "C:\Path\To\Your\Script\UpdateScript.ps1"
Using Get-WindowsUpdate
and the PSWindowsUpdate module in PowerShell provides a powerful way to manage Windows updates. Whether you need to check for, download, install, or schedule updates, these cmdlets offer a flexible and automated approach to keeping your systems up-to-date.