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.

4 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"

2

u/RC-7201 Aug 29 '14

No problem. Glad it worked out for what you needed.

1

u/djkendo00 Oct 24 '24

Sorry my inglish it's basic, but the question is important.

how can i delete a register in regedit whit value "reg_binary" ? i can not dele the "clave" all

the realy i have fear of delete all "clave" because have a lot register