Retrieve (Default) Value in Registry key Retrieve (Default) Value in Registry key powershell powershell

Retrieve (Default) Value in Registry key


maybe this can help:

(get-itemproperty -literalpath HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice).'(default)'

remember that if the value is not set it returns $null then also your method return the correct value ;)

Forgot to say that HKCR is not defined at default, use:

New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT

then you can do correctly:

(get-itemproperty -literalpath HKCR:\http\shell\open\command\).'(default)'


  1. If you want to use HKCR, to check for Classes in both HKCU and HKLM, you don't need to create a PSDrive, but use:

    (Get-ItemProperty Registry::HKCR\http\shell\open\command)."(Default)"# OR(Get-ItemProperty Registry::HKEY_CLASSES_ROOT\http\shell\open\command)."(Default)"
  2. Another way, which in some cases might be easier, is to use Method of RegistryKey object:

    (Get-Item -Path Registry::HKCR\http\shell\open\command).GetValue("")# OR(Get-Item -Path Registry::HKEY_CLASSES_ROOT\http\shell\open\command).GetValue("")

    This can also be used on results from Get-ChildItem Cmdlet


Although this has not been asked by the OP the following command might be helpful because it shows how easy it can be to search all (default) entries of all keys below a hive:

dir HKLM:\SOFTWARE\ -Recurse -ErrorAction Ignore | Get-ItemProperty -Name "(default)" -ErrorAction Ignore | Where-Object "(Default)" -like "*ocx" | Select-Object "(default)", PsPath

The command searches all registered OCX files in HKLM.

Since the output is not very readable I'll choose Convert-Path to make the registry path more readable:

dir HKLM:\SOFTWARE\ -Recurse -ErrorAction Ignore | Get-ItemProperty -Name "(default)" -ErrorAction Ignore | Where-Object "(Default)" -like "*ocx" | Select-Object @{n="OcxPath";e={$_."(default)"}},@{n="Regpath";e={Convert-Path $_.PsPath}}