From d981edea9c47843a52113e9e79e31ae6462477ea Mon Sep 17 00:00:00 2001 From: poslop Date: Wed, 14 Jan 2026 15:22:39 -0600 Subject: [PATCH] corrected ForegroundColor flag --- RemoveHKeyPrinters/RemoveHKeyPrinters.ps1 | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/RemoveHKeyPrinters/RemoveHKeyPrinters.ps1 b/RemoveHKeyPrinters/RemoveHKeyPrinters.ps1 index 37382f6..08cbd5f 100644 --- a/RemoveHKeyPrinters/RemoveHKeyPrinters.ps1 +++ b/RemoveHKeyPrinters/RemoveHKeyPrinters.ps1 @@ -6,7 +6,7 @@ if (!(Test-Path $flagFolder)) { } if (Test-Path $flagFile) { - Write-Host "Script has already run. Exiting." --ForegroundColor Red + Write-Host "Script has already run. Exiting." -ForegroundColor Red exit } @@ -27,13 +27,13 @@ $HKLMPrinterPaths = @( 'HKEY_LOCAL_MACHINE\SOFTWARE\Xerox\PrinterDriver' ) -Write-Host "Stopping spooler" --ForegroundColor Yellow +Write-Host "Stopping spooler" -ForegroundColor Yellow net stop spooler foreach ($HKLMPrinterPaths in $HKLMPrinterPaths) { try { Remove-Item -Path "Registry::${HKLMPrinterPaths}" -Recurse -Force -ErrorAction Stop - Write-Host "Removed local machine key ${HKLMPrinterPaths}" --ForegroundColor Green + Write-Host "Removed local machine key ${HKLMPrinterPaths}" -ForegroundColor Green } catch { Write-Host "Error: $($_.Exception.Message)" } @@ -46,7 +46,7 @@ foreach ($sidItem in $sids) { foreach ($HKUsersPrinterPath in $HKUsersPrinterPaths) { try { Remove-Item -Path "Registry::HKEY_USERS\${sid}${HKUsersPrinterPath}" -Recurse -Force -ErrorAction Stop - Write-Host "Removed user profile key HKEY_USERS\${sid}${HKUsersPrinterPath}" --ForegroundColor Green + Write-Host "Removed user profile key HKEY_USERS\${sid}${HKUsersPrinterPath}" -ForegroundColor Green } catch { Write-Host "Error: $($_.Exception.Message)" } @@ -55,31 +55,31 @@ foreach ($sidItem in $sids) { try { Remove-Item -Path "C:\Windows\System32\spool\PRINTERS" -Recurse -Force - Write-Host "Removed PRINTERS from spooler" --ForegroundColor Green + Write-Host "Removed PRINTERS from spooler" -ForegroundColor Green } catch { - Write-Host "Error Removing PRINTERS from spooler" --ForegroundColor Red + Write-Host "Error Removing PRINTERS from spooler" -ForegroundColor Red Write-Host "Error: $($_.Exception.Message)" } try { Remove-Item -Path "C:\Windows\System32\spool\V4Dirs" -Recurse -Force - Write-Host "Removed V4Dirs from spooler" --ForegroundColor Green + Write-Host "Removed V4Dirs from spooler" -ForegroundColor Green } catch { - Write-Host "Error Removing V4Dirs from spooler" --ForegroundColor Red + Write-Host "Error Removing V4Dirs from spooler" -ForegroundColor Red Write-Host "Error: $($_.Exception.Message)" } -Write-Host "Starting spooler" --ForegroundColor Yellow +Write-Host "Starting spooler" -ForegroundColor Yellow net start spooler -Write-Host "Running gpupdate" --ForegroundColor Yellow +Write-Host "Running gpupdate" -ForegroundColor Yellow gpupdate /force try { New-Item -Path $flagFile -ItemType File -Force - Write-Host "created flag at ${flagFile}" --ForegroundColor Green + Write-Host "created flag at ${flagFile}" -ForegroundColor Green } catch { - Write-Host "Could not create flag at ${flagFile}" --ForegroundColor Red + Write-Host "Could not create flag at ${flagFile}" -ForegroundColor Red Write-Host "Error: $($_.Exception.Message)" }