Category filter

Scripts to manage registry entries on Windows devices

The Windows registry is organized into a tree-like structure consisting of nodes called registry keys. These registry keys contain values called registry entries, which are properties of the corresponding registry key. You can customize and configure the system to suit your specific needs by managing registry entries on Windows devices.

While it is possible to modify the registry manually using the built-in Registry Editor tool, it can be time-consuming and error prone. This document focuses on scripts designed to manage registry entries efficiently. Use Hexnode’s Execute Custom Script feature to remotely deploy these scripts to multiple devices in no time.


The sample scripts provided below are adapted from third-party open-source sites.

PowerShell commands to manage registry entries in local machine registry

List the registry entries

The easiest way to examine registry entries is to get the name of the property associated with the key. A registry key has a property with the generic name “Property”, which is a list of registry entries in the key. The following command selects the Property attribute and expands the items so that they appear in the list:

For example, to display the list of entries in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control use the following script:

Display a list of all registry entries

For a more readable representation of the registry entries, you can use the Get-ItemProperty command.

Display the list of registry entries in a more readable form

You can navigate to the Control registry container using the Set-Location command. And, using the “.” notation for the current location helps list the properties without defining the full path.

Retrieve a single registry entry

Use the following command to retrieve a specific registry entry CurrentUser from the registry HKLM:\SYSTEM\CurrentControlSet\Control.

Retrieve a specific registry entry from a registry


The Get-ItemProperty command provides parameters such as Filter, Include, and Exclude, but they cannot be utilized for filtering by property name. The parameters are associated with registry keys, which refer to paths of items rather than registry entries, which refer to properties of items.

Create a new registry entry

To add a new item named “PowerShellPath” to the Control key, the New-ItemProperty command can be used with the key’s path, the entry name, and its corresponding value. In this example, it takes the value of the Windows PowerShell variable $PSHome, which stores the installation directory path for the program.

Create a new registry entry

To add a registry entry to multiple locations, you can provide an array of values for the Path parameter. For example:

Use Force parameter with any New-ItemProperty command to overwrite a pre-existing registry entry value.

To set the PropertyType, it is necessary to use the name of a member from the Microsoft.Win32.RegistryValueKind enumeration presented in the table below:

PropertyType Value Meaning
Binary Binary data
DWord A number that’s a valid UInt32
ExpandString A string that can contain environment variables that are dynamically expanded.
MultiString A multiline string
String Any string value
QWord 8 bytes of binary data

Rename a registry entry

Use the following command to rename the PowerShellPath entry to “PSHome”.

Delete the registry entries

Use the following command to delete PSHome registry entry.


  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository