Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Manage Windows Updates via Command Line and PowerShell

Windows Update is a crucial component of the Windows operating system, responsible for keeping your system up to date with the latest security patches, features, and improvements. While most users interact with Windows Update through the graphical interface, system administrators and power users may prefer managing updates via command line or PowerShell for automation and scripting purposes. This article will guide you through the process of managing Windows Updates using these tools.

Examples:

  1. Checking for Updates via Command Line:

    To check for updates using the Command Prompt, you can use the wuauclt command. However, please note that wuauclt is deprecated in newer versions of Windows. Instead, you should use PowerShell or the Windows Update Agent API. For older systems, you can try the following:

    wuauclt /detectnow

    This command forces Windows to check for updates immediately.

  2. Checking for Updates via PowerShell:

    PowerShell provides a more robust way to manage Windows Updates. You can use the Get-WindowsUpdate cmdlet from the PSWindowsUpdate module to check for updates:

    Install-Module -Name PSWindowsUpdate
    Import-Module PSWindowsUpdate
    Get-WindowsUpdate

    This series of commands installs the PSWindowsUpdate module, imports it, and checks for available updates.

  3. Installing Updates via PowerShell:

    Once you've checked for updates, you can install them using the Install-WindowsUpdate cmdlet:

    Install-WindowsUpdate -AcceptAll -AutoReboot

    This command installs all available updates and automatically reboots the system if necessary.

  4. Scheduling Updates via Task Scheduler:

    You can automate update checks by creating a scheduled task. Here’s a basic example using PowerShell to create a task that runs a script to check for updates:

    $Action = New-ScheduledTaskAction -Execute 'PowerShell.exe' -Argument '-NoProfile -WindowStyle Hidden -Command "Get-WindowsUpdate"'
    $Trigger = New-ScheduledTaskTrigger -Daily -At 3AM
    Register-ScheduledTask -Action $Action -Trigger $Trigger -TaskName "CheckWindowsUpdates" -Description "Daily check for Windows Updates"

    This script creates a scheduled task that runs daily at 3 AM to check for updates.

  5. Viewing Update History via Command Line:

    To view the update history, you can use the wmic command:

    wmic qfe list brief /format:table

    This command lists all installed updates in a table format.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.