Home » How to Get Registry Value in PowerShell

How to Get Registry Value in PowerShell

PowerShell provides a built-in cmdlet Get-ItemProperty to get the properties of the specified items, including the registry values.

The following methods can be used to get a registry value in PowerShell.

Method 1: Get Registry Value in PowerShell using Get-ItemProperty

# specify the registry key path
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\Application\"

# Get the registry value
Get-ItemProperty -Path $registryPath

This example returns the registry value for the specified path to the registry key $registryPath using the Get-ItemProperty cmdlet in PowerShell.

Method 2: Get the Registry Values with Get-ItemPropertyValue

# specify the registry key path
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\Application\"

# Get the registry value
Get-ItemPropertyValue -Path $registryPath -Name "MaxSize"

This example returns the MaxSize property value of the specified registry key $registryPath using the Get-ItemPropertyValue.

The following examples show how to use these methods.

Get Registry Value in PowerShell using Get-ItemProperty

To get registry value in PowerShell, you can use the Get-ItemProperty cmdlet. This command uses the -Path parameter to retrieve the registry value details from the path specified.

The following example shows how to do it with syntax.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# specify the registry key path
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\Application\"
# Get the registry value
Get-ItemProperty -Path $registryPath
# specify the registry key path $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\Application\" # Get the registry value Get-ItemProperty -Path $registryPath
# specify the registry key path
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\Application\"

# Get the registry value
Get-ItemProperty -Path $registryPath

Output:

PowerShell get registry value
PowerShell get registry value using Get-ItemProperty

In this example, the $registryPath variable holds the path to the registry key. The Get-ItemProperty cmdlet returns the registry value for the specified registry key.

Get the Registry Values with Get-ItemPropertyValue

Another way to get registry key values is by using the Get-ItemPropertyValue cmdlet in PowerShell. It gets the current value of a property located in a specified path.

The following example shows how to do this with syntax.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# specify the path to the registry key
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\Application\"
# Get the registry value
Get-ItemPropertyValue -Path $registryPath -Name "MaxSize"
# specify the path to the registry key $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\Application\" # Get the registry value Get-ItemPropertyValue -Path $registryPath -Name "MaxSize"
# specify the path to the registry key
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\Application\"

# Get the registry value
Get-ItemPropertyValue -Path $registryPath -Name "MaxSize"

Output:

PowerShell get registry value using Get-ItemPropertyValue
PowerShell get registry value using Get-ItemPropertyValue

In this example, the $registryPath variable holds the path to the registry key. The Get-ItemPropertyValue cmdlet in PowerShell retrieves a specific value from a registry key.

Conclusion

I hope the above article on getting registry value in PowerShell using the Get-ItemProperty cmdlet is helpful to you.

You can find more topics about Active Directory tools and PowerShell basics on the ActiveDirectoryTools home page.