Syntax error :/

This commit is contained in:
Yorick Barbanneau 2016-01-20 15:17:30 +01:00
parent 8898441184
commit e49c59da8a

View file

@ -23,19 +23,20 @@ function hide_update() {
$searcher.Online = $false $searcher.Online = $false
$criteria = "IsInstalled = 0" $criteria = "IsInstalled = 0"
$result = $searcher.Search($criteria) $result = $searcher.Search($criteria)
#$result.Updates | Foreach { Foreach ($update in $result.Updates) {
While ((!$found) -and ($i -lt $result.Updates.Count)) { $found = 0
if ($result.Updates.Item($i).KBArticleIDs -match $kb) { $kb | Foreach {
$found = 1 if ($update.KBArticleIDs -match $_) {
if (!$result.Updates.Item($i).IsHidden) { if (!$updates.Item($i).IsHidden) {
$result.Updates.Item($i).IsHidden = "True" $update($i).IsHidden = "True"
Write-Host -ForegroundColor green "Hidden" Write-Host -ForegroundColor green "Hidden"
} $found = 1
else { }
else {
Write-Host -ForegroundColor Yellow "Already hidden" Write-Host -ForegroundColor Yellow "Already hidden"
}
} }
} }
$i++
} }
if (!$found){ Write-Host -ForegroundColor Red "Not found"} if (!$found){ Write-Host -ForegroundColor Red "Not found"}
} }
@ -43,7 +44,7 @@ function hide_update() {
Foreach($kbID in $kbIDs){ Foreach($kbID in $kbIDs){
$kbNum = $kbID.Replace("KB","") $kbNum = $kbID.Replace("KB","")
Write-Host -NoNewline -ForegroundColor white "Uninstalling $kbID : " Write-Host -NoNewline -ForegroundColor white "Uninstalling $kbID : "
if (Get-HotFix -Id $kbID -ErrorAction SilentlyContinue)){ if (Get-HotFix -Id $kbID -ErrorAction SilentlyContinue){
Write-Host -NoNewline -ForegroundColor DarkGreen "found! " Write-Host -NoNewline -ForegroundColor DarkGreen "found! "
Write-Host -Nonewline -ForegroundColor white "removing ... " Write-Host -Nonewline -ForegroundColor white "removing ... "
wusa.exe /uninstall /KB:$kbNum /norestart /quiet /log:wsua.log wusa.exe /uninstall /KB:$kbNum /norestart /quiet /log:wsua.log