1

If you use the "old" windows inventory list "Change Or Remove a Program" you can find each software installed with: Name + Publisher + Installed On + Size + Version

I'm trying to obtain the exact same via powershell. My current method is:

$uninstallPath = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$uninstallWow6432Path = "\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
@(
    if (Test-Path "HKLM:$uninstallWow6432Path" ) { Get-ChildItem "HKLM:$uninstallWow6432Path"}
    if (Test-Path "HKLM:$uninstallPath" ) { Get-ChildItem "HKLM:$uninstallPath" }
    if (Test-Path "HKCU:$uninstallWow6432Path") { Get-ChildItem "HKCU:$uninstallWow6432Path"}
    if (Test-Path "HKCU:$uninstallPath" ) { Get-ChildItem "HKCU:$uninstallPath" }
) |
ForEach-Object { Get-ItemProperty $_.PSPath } |
Where-Object {
    $_.DisplayName -and !$_.SystemComponent -and !$_.ReleaseType -and !$_.ParentKeyName -and ($_.UninstallString -or $_.NoRemove)
} |
Sort-Object DisplayName | 
ForEach-Object -Process {
    echo "$($_.DisplayName);$($_.DisplayVersion);$($_.InstallDate)"
}

The main issue I have now, is some Softwares are missing the key "Installed On" (but that value is present on the "Change or Remove a program" page)

Is there a way to get a like for like inventory list?

Other options I have tried:

Fran
  • 3,693
  • 4
  • 19
  • 19
  • Was researching an answer for your question, thought I could find something, but found it harder than I anticipated. Then, as I was searching for `SystemComponent`, a keyword related to the registry, I discovered [this PowerShell script by John](https://stackoverflow.com/a/32574487/4190564) that he included with his C# answer. To be honest with you, that thing comes the closet yet of anything I've tried! – Darin Mar 23 '23 at 03:08
  • get-package .meta.Attributes – rinat gadeev Mar 23 '23 at 04:54
  • @rinatgadeev could you elaborate please? – Fran Mar 23 '23 at 11:12
  • @Darin that article is interesting but also basing itself on the registry info and for some of them the "Installed On" info is not there, while it is there on the UI With the above, I refactored my code, see question – Fran Mar 23 '23 at 11:14
  • @Fran, the problem appears to be that Microsoft's "Add or Remove Programs", or ARP, is getting it's data from the registry and possibly also other sources, and then filtering the data based on semi-secret criteria such as is whether the registry contains `SystemComponent`. From what I can tell, what little we know is thanks to people hacking and not from Microsoft releasing the info. The PowerShell code in the link in my comment produces the best results I've seen so far. I'll try to dig around some more, but for now that's all I have. – Darin Mar 23 '23 at 11:42
  • @Fran, I'm guessing what rinat gadeev meant is `(get-package).meta.Attributes`. Trying `(get-package).meta.Attributes | Format-List -Property *` produces some interesting results, but it's such a sea of information that I'm not sure what to do with it yet. – Darin Mar 23 '23 at 11:54
  • @Darin totally agree about that feeling of secret source for that UI. `(get-package -name 'DBeaver 22.3.5').meta.Attributes.Keys | Format-List -Property *` Dbeaver is one of the one giving me issues. If you use get-package, the "Installed on" info isn't there. It also feels like it's relying on registry keys (and Dbeaver doesn't have the info) – Fran Mar 23 '23 at 12:17
  • It seems random which programs have installdate and size (PS 5.1): `get-package -provider programs,msi | select name,@{n='installdate';e={$_.metadata['installdate']}},@{n='size';e={$_.metadata['size']}}` – js2010 Mar 23 '23 at 13:06

0 Answers0