Skip to content

Instantly share code, notes, and snippets.

@marcohald
Created February 23, 2022 12:25
Show Gist options
  • Save marcohald/2bc09e9a6fda3f3095bc5f874a4c6e6c to your computer and use it in GitHub Desktop.
Save marcohald/2bc09e9a6fda3f3095bc5f874a4c6e6c to your computer and use it in GitHub Desktop.
Parse the Logfile of Get-WindowsUpdateLog into a PsObject
Get-WindowsUpdateLog
$lines = Get-Content "$([System.Environment]::GetFolderPath("Desktop"))\WindowsUpdate.log"
$parsed = $lines | ForEach-Object {
[PSCustomObject]@{
'Timestamp' = $_.Substring(0,27)
'ProcessID' = $_.Substring(28,6).Trim()
'ThreadID' = $_.Substring(34,6).Trim()
'Task' = $_.Substring(40,15).Trim()
'Data' = $_.Substring(56)
}
}
$parsed | Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment