This function is part of the OZORegistry PowerShell Module.
Returns an OZORegistryKey object. This object may represent a new or existing registry key. The object contains methods for reading, adding, updating, and removing key names; and methods for displaying the key and--once all desired changes have been staged--for processing the changes to the key. This function (and resulting object) provide the most robust and flexible use of this module.
Get-OZORegistryKey
-Key <String>
-Display <Switch>
| Parameter | Description |
|---|---|
Key |
The registry key in the short (HKLM:\...) or long (HKEY_LOCAL_MACHINE\...) format. Key may be new or existing. |
Display |
Display console messages (effective only for user-interactive sessions). |
Return an object representing a registry key with console messages.
$ozoRegistryKey = (Get-OZORegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion" -Display)
Using key path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion.
Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion exists and all values read.
Name Type Value
---- ---- ----
ProgramFilesDir String C:\Program Files
CommonFilesDir String C:\Program Files\Common Files
ProgramFilesDir (x86) String C:\Program Files (x86)
CommonFilesDir (x86) String C:\Program Files (x86)\Common Files
CommonW6432Dir String C:\Program Files\Common Files
DevicePath ExpandString %SystemRoot%\inf
MediaPathUnexpanded ExpandString %SystemRoot%\Media
ProgramFilesPath ExpandString %ProgramFiles%
ProgramW6432Dir String C:\Program FilesReturn an object representing a registry key without console messages.
$ozoRegistryKey = (Get-OZORegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion")Return an object representing a registry key without console messages, and set the Display property to enable console messages. Note: For clarity and brevity, the remaining examples will omit console messages.
$ozoRegistryKey = (Get-OZORegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion")
$ozoRegistryKey.DisplayKeyValues()
$ozoRegistryKey.SetDisplay($true)
$ozoRegistryKey.DisplayKeyValues()
Name Type Value
---- ---- ----
ProgramFilesDir String C:\Program Files
CommonFilesDir String C:\Program Files\Common Files
ProgramFilesDir (x86) String C:\Program Files (x86)
CommonFilesDir (x86) String C:\Program Files (x86)\Common Files
CommonW6432Dir String C:\Program Files\Common Files
DevicePath ExpandString %SystemRoot%\inf
MediaPathUnexpanded ExpandString %SystemRoot%\Media
ProgramFilesPath ExpandString %ProgramFiles%
ProgramW6432Dir String C:\Program FilesGet the value and the type for the ProgramFilesDir name.
$ozoRegistryKey = (Get-OZORegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion")
$ozoRegistryKey.ReturnKeyNameValue("ProgramFilesDir")
C:\Program Files
$ozoRegistryKey.ReturnKeyNameType("ProgramFilesDIr")
StringGet add a new name to an existing registry key.
$ozoRegistryKey = (Get-OZORegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\One Zero One")
If (($ozoRegistryKey.AddKeyName("Version","1.0.0")) -eq $true) {
$ozoRegistryKey.ProcessChanges()
}Update an existing registry key name with a new value.
$ozoRegistryKey = (Get-OZORegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\One Zero One")
If (($ozoRegistryKey.UpdateKeyName("Version","2.0.0")) -eq $true) {
$ozoRegistryKey.ProcessChanges()
}Remove an existing name from a registry key
$ozoRegistryKey = (Get-OZORegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\One Zero One")
If (($ozoRegistryKey.UpdateName("Version")) -eq $true) {
$ozoRegistryKey.ProcessChanges()
}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.
For more information, please see the OZORegistryKey and OZORegistryKeyValue class definitions.