Last active
April 4, 2018 16:53
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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