1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
WSUSSearchByTargetGroups([string]$update){
[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer()
$wsus.SearchUpdates($update) | where { ( $_.'Title' -like '*2008 R2*' ) -or ( $_.'Title' -like '*7*') -or ( $_.'Title' -like '*XP*') } |
ForEach-Object{
[DateTime]::UtcNow.ToShortDateString()
$kbname = $_.KnowledgebaseArticles
$_.GetSummaryPerComputerTargetGroup()
}
}
$Choice = Get-Content updates.txt
foreach ($kb in $Choice)
{
write-host $kb
WSUSSearchByTargetGroups $kb | Format-table -hideTableHeaders -property InstalledCount,InstalledPendingRebootCount,DownloadedCount,NotInstalledCount,FailedCount,UnknownCount | Out-File updates.csv
$updatesfile = get-content updates.csv
$updatesfile = $updatesfile -replace('\s+',",")
$final = $updatesfile[0] + $updatesfile[2]
$final >> $("D:\Stats\" + $kb + ".csv")
del updates.csv
} |
Partager