Need some help with script that uses PSTools

Hi Everyone,

I am trying to run a script I found online which cleans out stale printers in the registry in Windows 2012. Here is what the code looks like:

Get-ItemProperty "HKLM:SYSTEMCurrentControlSetControlDeviceClasses{0ecef634-6ef0-472a-8085-5ad023ecbccd}##?#SWD#PRINTENUM#*"| Remove-Item -Recurse -Force Get-ItemProperty "HKLM:SYSTEMCurrentControlSetControlClass{1ed2bbf9-11f0-4084-b21f-ad83a8e6dcdc}*" -exclude "Properties" | Remove-Item -Recurse -Force Get-ItemProperty "HKLM:SYSTEMCurrentControlSetEnumSWDPRINTENUM*"| Remove-Item -Recurse -Force Get-ChildItem "HKLM:SYSTEMCurrentControlSetControlDeviceContainers" -ErrorAction SilentlyContinue -Recurse -exclude "{00000000-0000-0000-FFFF-FFFFFFFFFFFF}"|where-object {$_.property -like "SWDPRINTENUM*"}| foreach-object {(get-item $_.PSParentPath).PSParentPath}|Remove-Item -recurse -Force Get-childItem "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionPrintProvidersClient Side Rendering Print Provider*" | Remove-Item -Recurse -Force 

In order to run the first 4 lines, I need to have the code pass into PSExec which gives it elevated rights to delete the registry entries. Once I run the script manually, I get the following error:

https://imgur.com/Mg8BXhd

What am I doing wrong here?

submitted by /u/ImportantChicken562
[link] [comments]

Leave a Reply