This module provides functions and classes for interacting with the Microsoft Windows Registry.
Term | Definition |
---|---|
Hive | The registry is composed of several hives that each contain a hierarchy of keys. The image above shows the HKEY_LOCAL_MACHINE hive. |
Key | Each hive contains a hierarchy of keys that may contain other keys, and may contain zero or more names. The image above shows the One Zero One key in the SOFTWARE key in the HKEY_LOCAL_MACHINE hive. |
Name | Each key contains zero or more unique names. The image above shows the (default) and Acronym names in the One Zero One key. |
Value | Each name may be empty but will usually contain a value. The image above shows that the Acronym name contains the value OZO . |
Type | Each name has a type. Valid registry types are Binary , Dword , ExpandString , MultiString , Qword , and String . The image above shows the REG_SZ type (String) for the Acronym name. |
Each registry key name has a type. This table details the relationship between registry name types and PowerShell data types to help you align the data you are reading or writing in PowerShell with the corresponding registry data.
Registry Type | Registry Display | PowerShell Type | Description |
---|---|---|---|
Binary | REG_BINARY | Byte[] | Byte array |
Dword | REG_DWORD | Int32 | 32-bit unsigned integer |
ExpandString | REG_EXPAND_SZ | String | String that will be expanded when retrieved |
MultString | REG_MULTI_SZ | String[] | String array |
Qword | REG_QWORD | Int64 | 64-bit unsigned integer |
String | REG_SZ | String | A regular string |
Registry paths are generally expressed using one of two common formats, e.g., for HKEY_LOCAL_MACHINE
:
HKEY_LOCAL_MACHINE\SOFTWARE\One Zero One
HKLM:\SOFTWARE\One Zero One
Either format is acceptable for all functions in this module.
This module is published to PowerShell Gallery. Ensure your system is configured for this repository then execute the following in an Administrator PowerShell:
Install-Module OZORegistry
Import this module in your script or console to make the functions available for use:
Import-Module OZORegistry
- Convert-OZORegistryPath converts a registry string from one format to another.
- Read-OZORegistryKeyNameValue is a simple function for returning the value from a single registry key name.
- Read-OZORegistryKeyNameType is a simple function for returning the data type from a single registry key name.
- Write-OZORegistryKeyNameValue is a simple function for adding or updating the value for a single registry key name.
- Get-OZORegistryKey returns an
OZORegistryKey
object that represents a registry key (whether existing or not). The resulting object contains methods for reading, adding, updating, and removing key values; and a method for processing (writing) the changes to the registry. This function (and resulting object) is the most robust and flexible use of this module.
Messages as written to the Windows Event Viewer One Zero One provider when available. Otherwise, messages are written to the Microsoft-Windows-PowerShell provider under event ID 4100.
This module is licensed under the GNU General Public License (GPL) version 2.0.
Special thanks to my employer, Sonic Healthcare USA, who supports the growth of my PowerShell skillset and enables me to contribute portions of my work product to the PowerShell community.