I am new to PowerShell and I am trying to remove a specific value from the run registry key. I am using the remove-item
command, however, I don't see a switch to specify a single value. I don't want to remove the entire key, just one value.
For reference the batch equivalent of what I am trying to do:
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v SunJavaUpdateSched /f
From the left pane in Registry Editor, drill down until you locate the registry key you want to delete or the key that contains the registry value you want to remove. You can't delete registry hives, the top-level keys you see in the editor. Once found, right-click or tap-and-hold on it and choose Delete.
You can still use other tools you already have available to perform filesystem copies. Any registry editing tools—including reg.exe , regini.exe , regedit.exe , and COM objects that support registry editing, such as WScript. Shell and WMI's StdRegProv class can be used from within Windows PowerShell.
It is easy to change add registry keys and values. You can use the New-Item cmdlet to create any key in any registry hive. Once you create the key, you can use New-ItemProperty to set a registry value entry.
One of the easiest ways to find registry keys and values is using the Get-ChildItem cmdlet. This uses PowerShell to get a registry value and more by enumerating items in PowerShell drives.
Remove-ItemProperty -Name 'nameofkeyentry' -Path 'pathtothekey'
For example the key 'HKCU:\Accessibility\AudioDescription' has 3 values
(Default) REG_SZ (value not set)
Locale REG_SZ [blank]
On REG_SZ 0
Suppose we would like to remove the 3rd value 'On' - we would do so as follows
Remove-ItemProperty -Name 'On' -Path 'HKCU:\Accessibility\AudioDescription'
note HKCU stands for HKEY_CURRENT_USER, each root is abbreviated intuitively the same way (e.g. HKEY_CLASSES_ROOT = HKCR:\, etc)
use the cmdlet remove-itemproperty
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With