# Getting to the .default key in registry in powershell

**URL:** <https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240>\
**Category:** PowerShell Help\
**Created:** [April 17, 2016, 3:10am UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240 "2016-04-17T03:10:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![wei-yen-tan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/wei-yen-tan/32/91_2.png) [@wei-yen-tan](https://forums.powershell.org/u/wei-yen-tan)\
**Post date:** [April 17, 2016, 3:10am UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/1 "2016-04-17T03:10:57Z")

</div>

How would one get to the HKEY\_Users key in the registry using powershell? I am seeing that it would have to be possible to look it up by the .net classes.

One example I see is

```
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', 'computername')
```

Would the key be users in this case?  
The key that I am looking for is

HKEY\_Users.DEFAULT\Control Panel\International and the LocalName value.

Many thanks,

Wei-Yen

---

<div class="post-metadata">

**Author:** ![rdtechie](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rdtechie/32/273_2.png) [@rdtechie](https://forums.powershell.org/u/rdtechie)\
**Post date:** [April 17, 2016, 7:27am UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/2 "2016-04-17T07:27:52Z")

</div>

Simple, try this:

```
Set-Location -Path HCKU:
```

EDIT: I was too quick with answering. Be aware that you need to script this. There’s no native way (besides using .NET, as you already figured out), to access the .DEFAULT hive.

Check this: [https://www.sepago.com/blog/2007/11/19/why-is-almost-everybody-wrong-about-hkudefault](https://www.sepago.com/blog/2007/11/19/why-is-almost-everybody-wrong-about-hkudefault)  
And this: [registry - Loading ntuser.dat with powershell - Stack Overflow](http://stackoverflow.com/questions/11013466/loading-ntuser-dat-with-powershell)

---

<div class="post-metadata">

**Author:** ![curtis-smith](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/curtis-smith/32/121_2.png) [@curtis-smith](https://forums.powershell.org/u/curtis-smith)\
**Post date:** [April 17, 2016, 7:53am UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/3 "2016-04-17T07:53:24Z")

</div>

I’ve tried posting this a few times, but it has not shown up for some reason. Here it is again without the source reference which appears to be what it causing it to not display.

```
Get-ItemProperty -Path "Registry::\HKEY_USERS\.DEFAULT\Control Panel\International"
```

---

<div class="post-metadata">

**Author:** ![rdtechie](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rdtechie/32/273_2.png) [@rdtechie](https://forums.powershell.org/u/rdtechie)\
**Post date:** [April 17, 2016, 7:58am UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/4 "2016-04-17T07:58:01Z")

</div>

I take my words back. Curtis is the man! _0_

---

<div class="post-metadata">

**Author:** ![wei-yen-tan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/wei-yen-tan/32/91_2.png) [@wei-yen-tan](https://forums.powershell.org/u/wei-yen-tan)\
**Post date:** [April 17, 2016, 8:06am UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/5 "2016-04-17T08:06:55Z")

</div>

Thanks Richard.

---

<div class="post-metadata">

**Author:** ![rdtechie](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rdtechie/32/273_2.png) [@rdtechie](https://forums.powershell.org/u/rdtechie)\
**Post date:** [April 17, 2016, 8:08am UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/6 "2016-04-17T08:08:44Z")

</div>

You could use Invoke-Command for that.

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [April 17, 2016, 8:44am UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/7 "2016-04-17T08:44:54Z")

</div>

You could create a PSDrive using the Registry provider:

```
New-PSDrive HKU -Root HKEY_Users -PSProvider Registry
Get-ChildItem HKU:\.default
```

---

<div class="post-metadata">

**Author:** ![wei-yen-tan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/wei-yen-tan/32/91_2.png) [@wei-yen-tan](https://forums.powershell.org/u/wei-yen-tan)\
**Post date:** [April 17, 2016, 9:06am UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/8 "2016-04-17T09:06:23Z")

</div>

Thanks guys, you have given a bit more perspective

---

<div class="post-metadata">

**Author:** ![memoadmin](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@memoadmin](https://forums.powershell.org/u/memoadmin)\
**Post date:** [June 27, 2017, 3:47pm UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/9 "2017-06-27T15:47:11Z")

</div>

from cmd console:  
powershell -command “& Get-ChildItem -Path Registry::HKU | where {$\_.Name -match ‘Classes’} | Select-Object -ExpandProperty PSChildName | Out-File .\default\_HKU.txt”

from PS console:  
Get-ChildItem -Path Registry::HKU | where {$\_.Name -match ‘Classes’} | Select-Object -ExpandProperty PSChildName | Out-File .\default\_HKU.txt

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:38pm UTC](https://forums.powershell.org/t/getting-to-the-default-key-in-registry-in-powershell/6240/10 "2024-05-16T20:38:29Z")

</div>

Closed on May 16, 2024, 8:38pm UTC


