# Query Registry of a list of Hosts

**URL:** <https://forums.powershell.org/t/query-registry-of-a-list-of-hosts/12992>\
**Category:** PowerShell Help\
**Created:** [August 14, 2019, 1:23pm UTC](https://forums.powershell.org/t/query-registry-of-a-list-of-hosts/12992 "2019-08-14T13:23:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff-taylor](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jeff-taylor/32/1015_2.png) [@jeff-taylor](https://forums.powershell.org/u/jeff-taylor)\
**Post date:** [August 14, 2019, 1:23pm UTC](https://forums.powershell.org/t/query-registry-of-a-list-of-hosts/12992/1 "2019-08-14T13:23:38Z")

</div>

I am trying got query a key value in a few remote hosts on our domain. I wrote this:

```
$computers = Get-Content "E:\temp\list.txt"
    foreach($computer in $computers){
        $objReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer)
        $objRegKey= $objReg.OpenSubKey("\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" )
        $objRegkey.GetValueNames("ReleaseId")
}
```

…but get error:

```
You cannot call a method on a null-valued expression.
At line:5 char:9
+ $objRegkey.GetValueNames("ReleaseId")
```

There’s a value there so not sure why it errors. Can someone help please?

thank you

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 14, 2019, 2:59pm UTC](https://forums.powershell.org/t/query-registry-of-a-list-of-hosts/12992/2 "2019-08-14T14:59:27Z")

</div>

```
$objRegKey = $objReg.OpenSubKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion' )
$objRegKey.GetValue('ReleaseId')
```

---

<div class="post-metadata">

**Author:** ![jeff-taylor](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jeff-taylor/32/1015_2.png) [@jeff-taylor](https://forums.powershell.org/u/jeff-taylor)\
**Post date:** [August 14, 2019, 5:41pm UTC](https://forums.powershell.org/t/query-registry-of-a-list-of-hosts/12992/3 "2019-08-14T17:41:30Z")

</div>

Thanks Olaf, perfect.

---

<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:31pm UTC](https://forums.powershell.org/t/query-registry-of-a-list-of-hosts/12992/4 "2024-05-16T20:31:48Z")

</div>


