Search code examples
windowspowershellremote-debugginginstalled-applications

Get list of installed software of remote computer


Is it possible to get a list of installed software of a remote computer ? I know to do this for a local computer with use of Powershell. Is it possible with Powershell to get installed software of a remote computer and save this list on the remote computer ? This I use for local computers: Get-WmiObject -Class Win32_Product | Select-Object -Property Name

Thanks in advance, Best regards,


Solution

  • This uses Microsoft.Win32.RegistryKey to check the SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall registry key on remote computers.

    https://github.com/gangstanthony/PowerShell/blob/master/Get-InstalledApps.ps1

    *edit: pasting code for reference

    function Get-InstalledApps {
        param (
            [Parameter(ValueFromPipeline=$true)]
            [string[]]$ComputerName = $env:COMPUTERNAME,
            [string]$NameRegex = ''
        )
        
        foreach ($comp in $ComputerName) {
            $keys = '','\Wow6432Node'
            foreach ($key in $keys) {
                try {
                    $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $comp)
                    $apps = $reg.OpenSubKey("SOFTWARE$key\Microsoft\Windows\CurrentVersion\Uninstall").GetSubKeyNames()
                } catch {
                    continue
                }
    
                foreach ($app in $apps) {
                    $program = $reg.OpenSubKey("SOFTWARE$key\Microsoft\Windows\CurrentVersion\Uninstall\$app")
                    $name = $program.GetValue('DisplayName')
                    if ($name -and $name -match $NameRegex) {
                        [pscustomobject]@{
                            ComputerName = $comp
                            DisplayName = $name
                            DisplayVersion = $program.GetValue('DisplayVersion')
                            Publisher = $program.GetValue('Publisher')
                            InstallDate = $program.GetValue('InstallDate')
                            UninstallString = $program.GetValue('UninstallString')
                            Bits = $(if ($key -eq '\Wow6432Node') {'64'} else {'32'})
                            Path = $program.name
                        }
                    }
                }
            }
        }
    }