diff --git a/RemoveHKeyPrinters.ps1 b/RemoveHKeyPrinters.ps1 index 609f31d..6fc4e4d 100644 --- a/RemoveHKeyPrinters.ps1 +++ b/RemoveHKeyPrinters.ps1 @@ -14,7 +14,7 @@ $profileListKey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileLis $sids = Get-ChildItem $profileListKey -$printerPaths = @( +$HKUsersPrinterPaths = @( '\Printers\Connections', '\Printers\ConvertUserDevModesCount', '\Software\Xerox\PrinterDriver', @@ -42,10 +42,10 @@ foreach ($sidKey in $sids) { $sid = $sidKey.PSChildName $profilePath = (Get-ItemProperty -Path $sidKey.PSPath -Name ProfileImagePath).ProfileImagePath - foreach ($printerPath in $printerPaths) { + foreach ($HKUsersPrinterPath in $HKUsersPrinterPaths) { try { - Remove-Item -Path "Registry::HKEY_USERS\${sid}${printerPath}" -Recurse -Force -ErrorAction Stop - Write-Host "Removed user profile key HKEY_USERS\${sid}${printerPath}" --ForegroundColor Green + Remove-Item -Path "Registry::HKEY_USERS\${sid}${HKUsersPrinterPath}" -Recurse -Force -ErrorAction Stop + Write-Host "Removed user profile key HKEY_USERS\${sid}${HKUsersPrinterPath}" --ForegroundColor Green } catch { Write-Host "Error: $($_.Exception.Message)" }