From 2a1afae9185d10525c641732a4c5acf2268095dd Mon Sep 17 00:00:00 2001 From: Yorick Date: Tue, 2 Feb 2016 18:19:33 +0100 Subject: [PATCH] Reworked delete part --- remove-kb.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/remove-kb.ps1 b/remove-kb.ps1 index d9f03de..b5acf2b 100755 --- a/remove-kb.ps1 +++ b/remove-kb.ps1 @@ -100,9 +100,11 @@ if (Get-Process -name GWX -ErrorAction SilentlyContinue}) { else { Write-Host -ForegroundColor Yellow ("Not running")} #Remove GWX Files (test) -takeown /F "$env:WINDIR\System32\GWX" /R /D $yes -icacls "$env:WINDIR\System32\GWX" /C /grant $adminGroup":F" /T -Remove-Item $env:WINDIR\System32\GWX\* +takeown /F "$env:WINDIR\System32\GWX" /R /D $yes 2>&1 | Out-Null +icacls "$env:WINDIR\System32\GWX" /C /grant $adminGroup":F" /T 2>&1 | Out-Null +Try{ Remove-Item $env:WINDIR\System32\GWX\* -Force -Recurse -ErrorAction SilentlyContinue} +Catch {Write-Host -ForegroundColor Red "Some files can't be deleted."} + Foreach($kbID in $kbIDs){ $kbNum = $kbID.Replace("KB","")