Create a function and then call it with specific parameters.
########################################################
########################################################
Function Get-MSHotfix { $outputs = Invoke-Expression "wmic qfe list" $outputs = $outputs[1..($outputs.length)] foreach ($output in $Outputs) { if ($output) { $output = $output -replace 'y U','y-U' $output = $output -replace 'NT A','NT-A' $output = $output -replace '\s+',' ' $parts = $output -split ' ' if ($parts[5] -like "*/*/*") { $Dateis = [datetime]::ParseExact($parts[5], '%M/%d/yyyy',[Globalization.cultureinfo]::GetCultureInfo("en-US").DateTimeFormat) } else { $Dateis = get-date([DateTime][Convert]::ToInt64("$parts[5]", 16))-Format '%M/%d/yyyy' } New-Object -Type PSObject -Property @{ KBArticle = [string]$parts[0] Computername = [string]$parts[1] Description = [string]$parts[2] FixComments = [string]$parts[6] HotFixID = [string]$parts[3] InstalledOn = Get-Date($Dateis)-format "dddd d MMMM yyyy" InstalledBy = [string]$parts[4] InstallDate = [string]$parts[7] Name = [string]$parts[8] ServicePackInEffect = [string]$parts[9] Status = [string]$parts[10] } } } }
#############################################################
now call this function
Get-MSHotfix|Where-Object {$_.Installedon -gt ((Get-Date).Adddays(-2))}|Select-Object -Property Computername, KBArticle,InstalledOn, HotFixID, InstalledBy|Format-Table
No comments:
Post a Comment
Thanks for showing interest in tech-jockey.