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