How to delete registry key value (property) using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To delete the registry key value using PowerShell, we can use the Remove-ItemProperty command. Suppose we have the registry NodeSoftware and its Property is AppSecurity. We need to delete its key using the Remove-ItemProperty command.

PS C:\> Get-Item HKLM:\SOFTWARE\NodeSoftware
Hive: HKEY_LOCAL_MACHINE\SOFTWARE
Name    Property
----    --------
NodeSoftware    AppSecurity : 1

To delete the registry key,

PS C:\>Remove-ItemProperty HKLM:\SOFTWARE\NodeSoftware\ -Name AppSecurity -Force -Verbose
VERBOSE: Performing the operation "Remove Property" on target "Item: HKEY_LOCAL_MACHINE\SOFTWARE\NodeSoftware\ Property: AppSecurity".

You can also delete property by setting the location. For example,

Example

PS C:\> Set-Location HKLM:\SOFTWARE\NodeSoftware
PS HKLM:\SOFTWARE\NodeSoftware> Remove-ItemProperty -Path . -Name AppSecurity -Force -Verbose

To remove Item property using Pipeline,

Get-Item HKLM:\SOFTWARE\NodeSoftware | Remove-ItemProperty -Name AppSecurity -Force -Verbose
raja
Published on 08-Feb-2021 07:28:00
Advertisements