Clive
Clive

Reputation: 153

How to get a program's installation path using Powershell

I've tried to use Get-ChildItem to get installed program property information and it does provide some of the information I require but the Installed Location/path is usually blank. Given a program's name/displayname, is there a way reliable way to get the installation path of a Windows Server program (remote to other servers) using Powershell?

Thanks in advance.

Upvotes: 6

Views: 30419

Answers (2)

user11222805
user11222805

Reputation: 41

You can use these cmdlets to get the paths:

Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | % { Get-ItemProperty $_.PsPath } | Select DisplayName,InstallLocation | Sort-Object Displayname -Descending

Get-ChildItem HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | % { Get-ItemProperty $_.PsPath } | Select DisplayName,InstallLocation | Sort-Object Displayname -Descending

These show different programs and their locations.

Upvotes: 4

Avshalom
Avshalom

Reputation: 8889

Using Registry:

Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | 
% { Get-ItemProperty $_.PsPath } | Select DisplayName,InstallLocation

Using WMI:

Get-WmiObject -Class Win32_Product -Filter 'Name like "%Microsoft Office%"' | 
Select Caption,InstallLocation

For Remoting, Through registry it's totally different story, with WMI just add the -ComputerName Parameter (and make sure you have permissions)

Upvotes: 6

Related Questions