Retrieving all log events and files for update issues

On Windows machines, you may often have problems with your updates, either on downloading or applying them to the machines. In my troubleshooting days, I therefore created a little function to retrieve all important logs and event information: 

<#
.Synopsis
Gathers all Windows Update relevant logs from the local computer and open the file path.
.DESCRIPTION
Gathers all Windows Update relevant logs from the local computer - Get-Hotfix, Get-WindowsUpdateLog and all log in C:Windowslogs
.EXAMPLE
Get-WULogs
.EXAMPLE
Get-WULogs -LogFilePath 'D:Logs'
#>
function Get-WULogs
{
[CmdletBinding()]
Param
(
# LogFilePath
[Parameter
(Mandatory = $false,
Position = 0)]
$LogFilePath = 'c:TempWindowsUpdateLogs'
)
Begin
{
if (-not (Test-Path $LogFilePath))
{
New-Item -Path $LogFilePath -ItemType Directory
}
}
Process
{

#region variables
$WUDOFilePathCsv = [System.IO.Path]::Combine($LogFilePath, 'WUDOLog.Clixml')
$WUDOFilePathCli = [System.IO.Path]::Combine($LogFilePath, 'WUDOLog.Clixml')
$HotFixFilePathCsv = [System.IO.Path]::Combine($LogFilePath, 'Hotfix.csv')
$HotFixFilePathCli = [System.IO.Path]::Combine($LogFilePath, 'Hotfix.Clixml')
$WUFilePath = [System.IO.Path]::Combine($LogFilePath, 'WindowsUpdateEvents.csv')
$WUFilePathCli = [System.IO.Path]::Combine($LogFilePath, 'WindowsUpdateEvents.Clixml')
$GetWindowsUpdateLogOutFile = Join-Path -Path (Join-Path -Path ($Env:tmp) -ChildPath 'WindowsUpdateLog') -ChildPath "WindowsUpdateLog.log"
#endregion

#region Delivery Optimization logs
#Get WUDO log
$WUDOlog = Get-DeliveryOptimizationLog
$WUDOlog | Export-Csv $WUDOFilePathCsv
$WUDOlog | Export-Clixml $WUDOFilePathCli
#endregion

#region WinEvents
$WinEvents = Get-WinEvent -ProviderName Microsoft-Windows-WindowsUpdateClient
$WinEvents | Export-Clixml $WUFilePathCli
$WinEvents | Export-Csv $WUFilePath -Delimiter ';'
#endregion

#region HotFixes
$Hotfixes = Get-HotFix
$Hotfixes | Export-Clixml $HotFixFilePathCli
$Hotfixes | Export-Csv $HotFixFilePathCsv -Delimiter ';'
#endregion

#region WindowsUpdateLogs
#Get-WindowsUpdateLog -SymbolServer https://msdl.microsoft.com/download/symbols
Get-WindowsUpdateLog -LogPath $GetWindowsUpdateLogOutFile

Copy-Item -Path ($GetWindowsUpdateLogOutFile) -Destination (Join-Path -Path $LogFilePath -ChildPath 'WindowsUpdateLog.log')
Robocopy.exe 'c:Windowslogs' $([System.IO.Path]::Combine($LogFilePath, 'WindowsLogs')) /mir /MT:8 /R:0 /W:0
#endregion

#Open FilePath
Invoke-Item $LogFilePath
}
End
{}
}

You can easily make changes to this script and use it for your environment to retrieve consolidated troubleshooting information easily from the machines.

The WindowsUpdateLog sometimes has changes now with Windows 10. Read the following blog article to learn about the current approach in detail: 

https://blogs.technet.microsoft.com/mniehaus/2017/10/10/improved-windows-update-log-formatting-with-windows-10-1709/
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset