Does anyone know how to read out registry key values in PowerShell? The equivalent request in CMD can be seen on the picture.

equivalent in CMD


Get-ChildItem is the one to use, and a quickie would be:

Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion'

More examples here: https://msdn.microsoft.com/en-us/powershell/scripting/getting-started/cookbooks/working-with-registry-keys

If you want to get a specific key value:

$val = (Get-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName').ComputerName

And how to set/edit appropriately https://blogs.technet.microsoft.com/heyscriptingguy/2015/04/02/update-or-add-registry-key-value-with-powershell/


This format, while very similar can also be used:

$username = Get-ItemProperty -path "HKCU:\Volatile Environment"

Which creates an object. The properties can be called using:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.