Friends Of The Bitten Tadpole:
There wasn’t much in the way of examples on the greater Google for this one. One forum entry even said it was too difficult and suggested using regedit.exe, but in fact it is very easy. Look at the following example:
# Delete the Registry Key given in $deleteKey
Function DeleteRegistryKey($deleteKey)
{
$type = [Microsoft.Win32.RegistryHive]::LocalMachine
$Hive = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $RemoteMachine)
$Key = $Hive.DeleteSubKey($deleteKey)
}DeleteRegistryKey “Software\Microsoft\Whatever”
Too easy.
October 21, 2009 at 10:43 am |
But how about a directory hive with keys still in that hive? With this function, you can’t delete recursively. Nice and compact function, though.