Home > Mobile >  PowerShell command to get installed application/software version
PowerShell command to get installed application/software version

Time:08-24

I need to read product version from control panel for specific application. I'm using this command till now.

Get-WmiObject Win32_Product -Filter "Name like 'ISASmaartHub'" | Select-Object -ExpandProperty

after upgrading my system to Windows 11 it is throwing this exception -

Select-Object : Missing an argument for parameter 'ExpandProperty'. Specify a parameter of type 'System.String' and try again.
At line:1 char:82
  ...  -Filter "Name like 'ISASmaartHub'" | Select-Object -ExpandProperty
                                                            ~~~~~~~~~~~~~~~
      CategoryInfo          : InvalidArgument: (:) [Select-Object], ParameterBindingException
      FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.SelectObjectCommand

Can anyone please suggest which command I should use to read the version of an application on Windows 11 system.

Thanks in advance!

CodePudding user response:

  1. Prefer using Get-CimInstance over Get-WmiObject for new applications, as WMI is being deprecated.
  2. For WMI\CIM, operator LIKE uses WQL language and should have a % sign as a mark for Any symbols. WQL Like Syntax
  3. Select -ExpandProperty smth means from this big object select only value of smth property. This means, property name MUST present.

Working Example for product named 1C:

Get-CimInstance -Filter 'NAME LIKE "%"' -ClassName 'Win32_Product' | 
    Select -ExpandProperty 'Version'
  • Related