Remove-ADTRegistryKey
SYNOPSIS
Deletes the specified registry key or value.
SYNTAX
Path
Remove-ADTRegistryKey -Path <String> [-Name <String>] [-Wow6432Node] [-Recurse] [-SID <String>]
[<CommonParameters>]
LiteralPath
Remove-ADTRegistryKey -LiteralPath <String> [-Name <String>] [-Wow6432Node] [-Recurse] [-SID <String>]
[<CommonParameters>]
DESCRIPTION
This function deletes the specified registry key or value. It can handle both registry keys and values, and it supports recursive deletion of registry keys. If the SID parameter is specified, it converts HKEY_CURRENT_USER registry keys to the HKEY_USERS$SID format, allowing for the manipulation of HKCU registry settings for all users on the system.
EXAMPLES
EXAMPLE 1
Remove-ADTRegistryKey -LiteralPath 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce'
Deletes the specified registry key.
EXAMPLE 2
Remove-ADTRegistryKey -LiteralPath 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -Name 'RunAppInstall'
Deletes the specified registry value.
EXAMPLE 3
Remove-ADTRegistryKey -LiteralPath 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Example' -Name '(Default)'
Deletes the default registry value in the specified key.
EXAMPLE 4
Remove-ADTRegistryKey -Path 'HKEY_LOCAL_MACHINE\SOFTWARE\MyCustomKey\*' -Recurse
Removes all subkeys from HKEY_LOCAL_MACHINE\SOFTWARE\MyCustomKey
as requested.
EXAMPLE 5
Remove-ADTRegistryKey -Path 'HKEY_LOCAL_MACHINE\SOFTWARE\MyCustomKey\*' -Name 'PropertyName'
Removes PropertyName
from all subkeys of HKEY_LOCAL_MACHINE\SOFTWARE\MyCustomKey
.
PARAMETERS
-Path
Path of the registry key to delete, wildcards permitted.
Type: String
Parameter Sets: Path
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
-LiteralPath
Literal path of the registry key to delete.
Type: String
Parameter Sets: LiteralPath
Aliases: Key
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Name
Name of the registry value to delete.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: [System.Management.Automation.Language.NullString]::Value
Accept pipeline input: False
Accept wildcard characters: False
-Wow6432Node
Specify this switch to read the 32-bit registry (Wow6432Node) on 64-bit systems.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Recurse
Delete registry key recursively.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-SID
The security identifier (SID) for a user. Specifying this parameter will convert a HKEY_CURRENT_USER registry key to the HKEY_USERS$SID format.
Specify this parameter from the Invoke-ADTAllUsersRegistryAction function to read/edit HKCU registry settings for all users on the system.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
None
You cannot pipe objects to this function.
OUTPUTS
None
This function does not generate any output.
NOTES
An active ADT session is NOT required to use this function.
Tags: psadt
Website: https://psappdeploytoolkit.com
Copyright: (C) 2025 PSAppDeployToolkit Team (Sean Lillis, Dan Cunningham, Muhammad Mashwani, Mitch Richters, Dan Gough).
License: https://opensource.org/license/lgpl-3-0
RELATED LINKS
https://psappdeploytoolkit.com/docs/reference/functions/Remove-ADTRegistryKey