Export-UpdateLog
Collect the update logs. Zips CBS.log, the DISM log and the Windows Update log. Read only.
Fixes these codes
What it does
Microsoft's update troubleshooting articles start with "open the last CBS.log and look for the error near its time stamp". This script gathers the logs for you:
C:\Windows\Logs\CBS\CBS.log
C:\Windows\Logs\DISM\dism.log
a fresh Windows Update log built with Get-WindowsUpdateLog
It copies them to a temporary folder, zips them to the destination and removes the temporary folder. Nothing is uploaded. The logs can contain computer names, user names and file paths. Check them before sending them outside your organization.
Parameters
-Destination: The folder for the zip file. The default is the current user's Desktop.
Examples
.\Export-UpdateLog.ps1
Writes the zip to the Desktop.
.\Export-UpdateLog.ps1 -Destination D:\Cases
Writes the zip to D:\Cases.
Microsoft's guidance
The script
Click the script to select all of it, then copy. Fingerprint of this text (SHA-256): 67a0324457c694246aa66654e103151fe9a07a5d41b3255c541247f1247e7dba. Updated 2026-10-21.
# Copyright (c) 2026 Owen Perry. All rights reserved.
#Requires -Version 5.1
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Collects the Windows Update and servicing logs into one zip file. Changes nothing on the system.
.DESCRIPTION
Microsoft's update troubleshooting articles start with "open the last CBS.log and look for the error near its time stamp". This script gathers the logs for you:
C:\Windows\Logs\CBS\CBS.log
C:\Windows\Logs\DISM\dism.log
a fresh Windows Update log built with Get-WindowsUpdateLog
It copies them to a temporary folder, zips them to the destination and removes the temporary folder. Nothing is uploaded.
The logs can contain computer names, user names and file paths. Check them before sending them outside your organization.
.PARAMETER Destination
The folder for the zip file. The default is the current user's Desktop.
.EXAMPLE
.\Export-UpdateLog.ps1
Writes the zip to the Desktop.
.EXAMPLE
.\Export-UpdateLog.ps1 -Destination D:\Cases
Writes the zip to D:\Cases.
.LINK
https://learn.microsoft.com/en-us/troubleshoot/windows-client/installing-updates-features-roles/troubleshoot-windows-update-error-0x80070005
#>
[CmdletBinding()]
param([string]$Destination = [Environment]::GetFolderPath('Desktop'))
$ErrorActionPreference = 'Stop'
$stamp = '{0:yyyyMMdd-HHmmss}' -f (Get-Date)
$workFolder = Join-Path $env:TEMP "update-logs-$stamp"
New-Item -ItemType Directory -Path $workFolder -Force | Out-Null
try {
# Copy the two logs that Microsoft's articles point to. A missing log is a warning, not a stop.
foreach ($log in "$env:windir\Logs\CBS\CBS.log", "$env:windir\Logs\DISM\dism.log") {
if (Test-Path -LiteralPath $log) {
Copy-Item -LiteralPath $log -Destination $workFolder
} else {
Write-Warning "Not found: $log"
}
}
# Windows Update writes its log in a binary format. This command converts it to text.
try {
Get-WindowsUpdateLog -LogPath (Join-Path $workFolder 'WindowsUpdate.log') | Out-Null
} catch {
Write-Warning "Get-WindowsUpdateLog failed: $($_.Exception.Message)"
}
New-Item -ItemType Directory -Path $Destination -Force | Out-Null
$zipFile = Join-Path $Destination "update-logs-$env:COMPUTERNAME-$stamp.zip"
Compress-Archive -Path (Join-Path $workFolder '*') -DestinationPath $zipFile
Write-Host "Wrote $zipFile"
} finally {
# Remove the temporary copies.
Remove-Item -LiteralPath $workFolder -Recurse -Force -ErrorAction SilentlyContinue
}