# Query remote registry

**URL:** <https://forums.powershell.org/t/query-remote-registry/23694>\
**Category:** PowerShell Help\
**Created:** [March 1, 2024, 4:01pm UTC](https://forums.powershell.org/t/query-remote-registry/23694 "2024-03-01T16:01:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mveden82](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Mveden82](https://forums.powershell.org/u/Mveden82)\
**Post date:** [March 1, 2024, 4:01pm UTC](https://forums.powershell.org/t/query-remote-registry/23694/1 "2024-03-01T16:01:47Z")

</div>

I’m trying to query a registry on a remote computer for installed software using the following script:

Get-Content -Path c:\temp\pcs.txt | ForEach-Object {Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate} | Where-Object DisplayName -ne $null | Export-CSV “C:\Temp\Software\Csv\Export.csv”

It works, but for some reason I get a diffrent output when I do it remotely as to when I run it locally. Remotely it sees applications it does not see when ran locally and vice versa.

Anyone any idea as to why this could be?

Thanks,  
Max.

---

<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:** [March 1, 2024, 6:27pm UTC](https://forums.powershell.org/t/query-remote-registry/23694/2 "2024-03-01T18:27:02Z")

</div>

Hi, welcome to the forum 👋

Firstly, when posting code or data in the forum, please can you use the preformatted text \</\> button. It really helps us with readability, and copying and pasting your code (we don’t have to faff about replacing curly quote marks to get things working). If you can’t see the \</\> in your toolbar, you will find it under the gear icon.

[How to format code on PowerShell.org](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif)

In the code you’ve posted you’re not connecting to a remote machine, you’re querying the same item properties on your local machine as many times as you have PCs in pcs.txt

---

<div class="post-metadata">

**Author:** ![Mveden82](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Mveden82](https://forums.powershell.org/u/Mveden82)\
**Post date:** [March 7, 2024, 8:29am UTC](https://forums.powershell.org/t/query-remote-registry/23694/3 "2024-03-07T08:29:24Z")

</div>

Hi Matt,

Sorry it took me a while to respond (I was out sick), is there a way to edit my post to format the text?

As for the script itself, how would I go about connecting to each pc in the pcs.txt to run the script on each?

---

<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:** [March 7, 2024, 10:08pm UTC](https://forums.powershell.org/t/query-remote-registry/23694/4 "2024-03-07T22:08:19Z")

</div>

If you can see it, use the pencil icon to edit your post. I’m not sure if this option is immediately available to new members as it’s common for spammers to edit their posts so if you can’t see it you may need to spend more time here / post more often before the forum software grants you that right.

You can use `Invoke-Command` to run commands on remote computers. The latest version of the help is linked below, be sure to read the help for your version of PowerShell if you’re not running 7.4.x.

> **[Invoke-Command (Microsoft.PowerShell.Core) - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-7.4)**
>
> The Invoke-Command cmdlet runs commands on a local or remote computer and returns all output from the commands, including errors. Using a single Invoke-Command command, you can run commands on multiple computers. To run a single command on a remote...

For more information on remoting in general, see the topic about\_Remote.

> **[about Remote - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote?view=powershell-7.4)**
>
> Describes how to run remote commands in PowerShell.

---

<div class="post-metadata">

**Author:** ![Mveden82](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Mveden82](https://forums.powershell.org/u/Mveden82)\
**Post date:** [March 8, 2024, 7:52am UTC](https://forums.powershell.org/t/query-remote-registry/23694/5 "2024-03-08T07:52:54Z")

</div>

Thanks for your reaction, I don’t see the pencil on my original post but do see it on my reply 😃

Thanks for the links, I’ll go over them

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 7, 2024, 7:53am UTC](https://forums.powershell.org/t/query-remote-registry/23694/6 "2024-04-07T07:53:26Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
