Skip to content

Instantly share code, notes, and snippets.

@keithga
Last active April 4, 2018 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithga/2276eea9eb155a00767e02906bd82939 to your computer and use it in GitHub Desktop.
Save keithga/2276eea9eb155a00767e02906bd82939 to your computer and use it in GitHub Desktop.
BLOG: example of how to work arround Get-WindowsUpdateLog console issues in a SCCM Configuration Item
<#
.SYNOPSIS
Search WindowsUpdate Logs
.DESCRIPTION
Searches the Windows Update Log for a string
.NOTES
Ready to be used within a
Copyright Keith Garner, All rights reserved.
.LINK
https://keithga.wordpress.com/2018/04/03/out-default-considered-harmful
#>
[cmdletbinding()]
param(
[parameter(Mandatory=$true)]
$SearchString,
$CleanWU,
$ETLPath = "$env:WinDir\Logs\WindowsUpdate"
)
$WULog = New-TemporaryFile
# Hack Hack to work arround Windows Update SCCM Config Item interop issue.
if ( -not ( test-path alias:out-default ) ) { new-alias Out-Default Write-Verbose -Scope global }
Get-WindowsUpdateLog -LogPath $WULog -ETLPath $ETLPath
remove-item alias:Out-Default -force -EA SilentlyContinue
$WUResults = Select-String -path $WULog -Pattern $SearchString -AllMatches
if ( $WUResults ) {
write-host "Not Compliant $($WUResults.Count) $env:computerName"
$wuresults | out-string -Width 200 | write-verbose
}
else {
write-host "Compliant"
}
if ( $CleanWU ) {
write-verbose "Cleanup"
remove-item -Recurse -Force -Path $env:temp\WindowsUpdateLog
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment