Sunday, May 13, 2007

Getting the "default" registry value entry with PowerShell

Want to get to the 'default' registry value using Powershell?. If so, set-itemproperty -path 'your path' -name '(Default)' -value 'your value'  should do the trick as shown here:

PS C:\> cd KHCU:
mkdir test

Hive: Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER

SKC VC Name Property
--- -- ---- --------
0 0 test {}

PS HKCU:\> get-itemproperty test  # not no output - entry does not exist
PS HKCU:\> set-itemproperty -path test -name '(Default)' -value 'some value'
PS HKCU:\> get-itemproperty test
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\test
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER
PSChildName : test
PSDrive : HKCU
PSProvider : Microsoft.PowerShell.Core\Registry (default) : some value



No comments: