From 70019eaa8fed396bce7b7965b07525c78fe47af6 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Tue, 12 Jul 2022 09:10:32 +0200 Subject: [PATCH] [Windows] Replace Win32_Product call to registry query (#5887) * Replace Win32_Product call to registry query * Update properties --- .../scripts/SoftwareReport/SoftwareReport.Tools.psm1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index 878a838c2..e85b328fe 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -277,13 +277,17 @@ function Get-GHVersion { } function Get-VisualCPPComponents { - $vcpp = Get-CimInstance -ClassName Win32_Product -Filter "Name LIKE 'Microsoft Visual C++%'" - $vcpp | Sort-Object Name, Version | ForEach-Object { - $isMatch = $_.Name -match "^(?Microsoft Visual C\+\+ \d{4})\s+(?\w{3})\s+(?.+)\s+-" + $regKeys = @( + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" + "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" + ) + $vcpp = Get-ItemProperty -Path $regKeys | Where-Object DisplayName -like "Microsoft Visual C++*" + $vcpp | Sort-Object DisplayName, DisplayVersion | ForEach-Object { + $isMatch = $_.DisplayName -match "^(?Microsoft Visual C\+\+ \d{4})\s+(?\w{3})\s+(?.+)\s+-" if ($isMatch) { $name = '{0} {1}' -f $matches["Name"], $matches["Ext"] $arch = $matches["Arch"].ToLower() - $version = $_.Version + $version = $_.DisplayVersion [PSCustomObject]@{ Name = $name Architecture = $arch