0

I need to get the details of a particular software for eg: Chrome in json format.
The below command shows output of all the softwares in Json format.

Get-WmiObject -Class Win32_Product | select-object name,version,vendor,InstallDate,InstallLocation | ConvertTo-Json

But I need to grep only for chrome. I get the output as below, but it is not in json format.

Get-WmiObject -Class Win32_Product | select-object name,version,vendor,InstallDate | Select-String 'Chrome'

@{name=Google Chrome; version=60.0.3xxx; vendor=Google, Inc.; InstallDate=20180909}

Is there any command for this?

2 Answers 2

2

I would avoid using win32_product, see win32_product-is-evil

Here's an alternative which should run a lot faster:

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, 
                 HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | 
    Where-Object {$_.DisplayName -like '*chrome*'} |
    Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | 
    ConvertTo-Json

Output

{
"DisplayName":  "Google Chrome",
"DisplayVersion":  "79.0.3945.130",
"Publisher":  "Google LLC",
"InstallDate":  "20191113"
}

If you want to search for 32 bit applications, use the following registry:

HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
Sign up to request clarification or add additional context in comments.

8 Comments

This would be nice, but Google Chrome does not appear in the output on my machine. $PSVersionTable.PSVersion.ToString() => 5.1.17763.1007
Maybe you have the 32bit version? See my revision.
[Environment]::Is64BitProcess => True
True, but I don't think its a big overhead, I have updated the example as you can simply combine the search paths
Wow, we are going way off topic here, win32_product won't work on Mac or Linux which was the original question.
|
1

The products need to be filtered with Where-Object. Get-WmiObject is superceded by Get-CimInstance in PowerShell 3.0.

Get-CimInstance -Class CIM_Product |
    Select-Object -Property Name,Version,Vendor,InstallDate |
    Where-Object { $_.Name -match 'Chrome' }

Get-CimInstance -Class CIM_Product |
    Select-Object -Property Name,Version,Vendor,InstallDate |
    Where-Object { $_.Name -match 'Chrome' } |
    ConvertTo-Json

PS C:\> Get-CimInstance -Class CIM_Product |
>>     Select-Object -Property Name,Version,Vendor,InstallDate |
>>     Where-Object { $_.Name -match 'Chrome' } |
>>     ConvertTo-Json
>>
{
    "Name":  "Google Chrome",
    "Version":  "84.0.4147.135",
    "Vendor":  "Google LLC",
    "InstallDate":  "20191126"
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.