I need help with a Powershell Script I need to delete any Registry keys, values or Dwords
We updated our print server. I need to remove any Values, Friendly names, or DWORDs that reference the old print server. The old printers were pushed out via GPO by username, and we have computers with up to 50 copies of the same printer, I already tried editing the deployment scripts that did not remove them. I found a few scripts, but none of them seem to remove all of the entries
Here is one of the scrips I am trying to edit
$PrinterReg = Get-ChildItem -Path Registry::HKLMSYSTEMCurrentControlSetEnumSWDPRINTENUM*
$PrinterName = “\Starbase16*”
Foreach ($DeletePrinter in $PrinterReg){
$FriendlyName = $DeletePrinter.GetValue(“Friendlyname”)
if($FriendlyName -eq $PrinterName){
Remove-Item -path $DeletePrinter.PSPath -Recurse
Write-Host “Removing $friendlyname from $($DeletePrinter.PSPath)”
}}
Here are all the Keys that contain Starbase16
ComputerHKEY_CURRENT_USERPrintersConvertUserDevModesCount
ComputerHKEY_CURRENT_USERPrintersSettings
ComputerHKEY_CURRENT_USERSoftwareMicrosoftTerminal Server ClientServersStarbase16
ComputerHKEY_CURRENT_USERSoftwareXeroxPrinterDriverV5.0“Starbase16`2E-Main-Mailroom
ComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintPrinterMigrationExCSR|Starbase16
ComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintPrintersStarbase16
ComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintProvidersClient Side Rendering Print ProviderS-1-5-21-117609710-602162358-725345543-28548PrintersConnections
ComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintProvidersClient Side Rendering Print ProviderServersStarbase16MonitorsClient Side Port
ComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintProvidersClient Side Rendering Print ProviderServersStarbase16Printers
We updated our print server. I need to remove any Values, Friendly names, or DWORDs that reference the old print server. The old printers were pushed out via GPO by username, and we have computers with up to 50 copies of the same printer, I already tried editing the deployment scripts that did not remove them. I found a few scripts, but none of them seem to remove all of the entriesHere is one of the scrips I am trying to edit$PrinterReg = Get-ChildItem -Path Registry::HKLMSYSTEMCurrentControlSetEnumSWDPRINTENUM*$PrinterName = “\Starbase16*”Foreach ($DeletePrinter in $PrinterReg){$FriendlyName = $DeletePrinter.GetValue(“Friendlyname”)if($FriendlyName -eq $PrinterName){Remove-Item -path $DeletePrinter.PSPath -RecurseWrite-Host “Removing $friendlyname from $($DeletePrinter.PSPath)”}}Here are all the Keys that contain Starbase16 ComputerHKEY_CURRENT_USERPrintersConvertUserDevModesCountComputerHKEY_CURRENT_USERPrintersSettingsComputerHKEY_CURRENT_USERSoftwareMicrosoftTerminal Server ClientServersStarbase16ComputerHKEY_CURRENT_USERSoftwareXeroxPrinterDriverV5.0“Starbase16`2E-Main-MailroomComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintPrinterMigrationExCSR|Starbase16ComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintPrintersStarbase16ComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintProvidersClient Side Rendering Print ProviderS-1-5-21-117609710-602162358-725345543-28548PrintersConnectionsComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintProvidersClient Side Rendering Print ProviderServersStarbase16MonitorsClient Side PortComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionPrintProvidersClient Side Rendering Print ProviderServersStarbase16Printers Read More