0

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!

3
  • 1
    This would not have worked on Win10 either. Change Select-Object -ExpandProperty to Select-Object -ExpandProperty Version Commented Aug 23, 2022 at 10:45
  • 1
    As a tip I can give you: don't use win32_product, it's broken (very slow and it can actually reset software settings in some rare cases because of the consistency check). See learn.microsoft.com/en-us/powershell/scripting/samples/… for more info Commented Aug 23, 2022 at 11:11
  • Thank you, I'm able to get the version now using Get-CimInstance as well as Get-WmiObject. As suggested will go with Get-CimInstance. Commented Aug 23, 2022 at 14:00

1 Answer 1

2
  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 "%1C%"' -ClassName 'Win32_Product' | 
    Select -ExpandProperty 'Version'
Sign up to request clarification or add additional context in comments.

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.