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:
- Prefer using
Get-CimInstance
overGet-WmiObject
for new applications, as WMI is being deprecated. - For WMI\CIM, operator LIKE uses WQL language and should have a
%
sign as a mark forAny symbols
. WQL Like Syntax Select -ExpandProperty smth
means from this big object select only value ofsmth
property. This means, property name MUST present.
Working Example for product named 1C
:
Get-CimInstance -Filter 'NAME LIKE "%"' -ClassName 'Win32_Product' |
Select -ExpandProperty 'Version'