Query remote registry

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.

Hi, welcome to the forum :wave:

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

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

2 Likes

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?

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.

For more information on remoting in general, see the topic about_Remote.

1 Like

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

Thanks for the links, I’ll go over them

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