Get WindowsUpdateLog - PowerShell


Overview

Get-WindowsUpdateLog retrieves a specified Windows Update log from the local system or a remote computer. These logs provide detailed information about Windows Update deployments, including installation attempts, errors, and successes.

Syntax

Get-WindowsUpdateLog [-LogFilePath] <String> [-FilePath] <String> [-Date] <DateTime> [-NoWrap] [-Online] [-AllowRedirect] [-UseBasicParser] [-ComputerName] <String> [-Credential] <PSCredential>

Options/Flags

  • -LogFilePath: Specifies the path to the Windows Update log file in XML format.
  • -FilePath: Specifies the path to the destination file where the log will be saved.
  • -Date: Filters the logs by the specified date.
  • -NoWrap: Prevents the output from wrapping to the next line.
  • -Online: Retrieves logs from Microsoft Update.
  • -AllowRedirect: Allows the command to follow HTTP redirects.
  • -UseBasicParser: Uses a simplified parser to prevent log file corruption.
  • -ComputerName: Specifies the name of the remote computer from which to retrieve the log.
  • -Credential: Specifies the credentials to use when connecting to a remote computer.

Examples

Example 1: Retrieve the latest Windows Update log

Get-WindowsUpdateLog

Example 2: Retrieve a specific log by date

Get-WindowsUpdateLog -Date "2023-03-08"

Example 3: Save the log to a file

Get-WindowsUpdateLog -FilePath "C:\WindowsUpdateLog.xml"

Common Issues

  • The log file may be corrupted or in the wrong format. Ensure the file path is correct and use the -UseBasicParser flag if necessary.
  • Access denied errors may occur when accessing remote computers. Verify the provided credentials have appropriate permissions.

Integration

Get-WindowsUpdateLog can be combined with other commands to perform advanced tasks:

  • Get-WindowsUpdateLog | Select-String “Error”: Filter the log for error messages.
  • Get-WindowsUpdateLog -Online | ForEach-Object {Invoke-WebRequest $_.Url}: Download update files from Microsoft Update.
  • Get-WindowsUpdate
  • Get-WUHistory