Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WMI not return all install programs on Windows 7 64

Tags:

windows

wmi

Today we try to list all installed programs on each VM with following script to query WMI.

We find out it will list out all 64 bit applications, plus some of 32 bit applications.
But not all applications (32bit + 64bit) will list out.

param(
    [string] $ExportPath = ''
)

$InstalledProducts = get-wmiobject -class Win32_Product

if (($InstalledProducts -ne $null) -and ($InstalledProducts.Count -gt 0))
{
    $fileName = ($env:COMPUTERNAME) + "-" +  (Get-Date -f "yyyy-mm-dd-hhmmss") +  ".csv"
    $fileExport = $fileName
    if(Test-Path $ExportPath) {
        $fileExport = Join-Path (Resolve-Path $ExportPath) $fileName
    }
    $InstalledProducts | 
        Select-Object @{Name="HostName"; Expression={"$env:COMPUTERNAME"}}, Name, Version, Vendor | 
        Export-CSV -Path $fileExport -Encoding UTF8
}
else
{
    Write-Host "!!!ERROR!!!"
}

We also try "wmic product" it has the similar issue.
https://superuser.com/questions/681564/how-to-list-all-applications-displayed-from-add-remove-winxp-win7-via-command-li

like image 933
Amitabha Avatar asked Nov 28 '25 04:11

Amitabha


1 Answers

At last, we need to merge all items both in

HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall

HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

Code:

param (
    [String] $ExportPath = '<NetworkPath>'
)

$fileName = ($ENV:COMPUTERNAME) + "-" + (Get-Date -f "yyyy-mm-dd-HHmmss") + ".csv"
$fileExport = $fileName

if (Test-Path $ExportPath) {
    $fileExport = Join-Path (Resolve-Path $ExportPath) $fileName
}

$UninstallRegList = ('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
    'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')

$UninstallRegList |
    Get-ItemProperty |
    foreach{
        if (($_.DisplayName -ne $NULL) -and ($_.DisplayName -ne "")){
            $_
        }
    } | Select-Object DisplayName, DisplayVersion, Publisher |
    Export-CSV -Path $fileExport -Encoding UTF8

Here post explains that

The Win32_InstalledSoftwareElement and Win32_Product will only give you information about software that is installed by Microsoft Installer.

ref: WMI "installed" query different from add/remove programs list?

like image 197
Amitabha Avatar answered Nov 29 '25 17:11

Amitabha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!