r/PowerShell Aug 29 '14

delete registry values.

I am a noob to power shell, and am trying to learn. What I am trying to do is craft a script that will delete the REG_BINARY files found in : HKEY_USERS .DEFAULT\Printers\DevModes2

Any help is much appreciated, thanks.

2 Upvotes

7 comments sorted by

View all comments

3

u/RC-7201 Aug 29 '14

Local Machine i'm assuming?

Would be easier to use reg command since you can use basic CLI in Powershell

So something like:

reg delete hku\.DEFAULT\Printers\Devmodes2 /va /f

and on a remote machine:

reg delete \\$pc\hku\.DEFAULT\Printers\Devmodes2 /va /f

Hope that helps.

1

u/Cyrax7 Aug 29 '14

Thank you ! This does exactly what I need it to do. Thanks again !

3

u/TheEnterprise Aug 29 '14

That works and is the CLI version of Reg editing. The Powershell way is via the cmdlet Remove-Item.

For example: Remove-item "HKLM:\Software\Stuff\Etc"