locked
wmic /namespace:\\root\cimv2 path win32_product where "name like '%%.NET%%'" get version fails RRS feed

  • Question

  • Hi All,

    When I run following command, it always shows "No Instance(s) available". I have enabled both .net 3.5 and 4.5 roles, what could be the issue?

    wmic /namespace:\\root\cimv2 path win32_product where "name like '%%.NET%%'" get version

    No Instance(s) Available.

    Thanks!

    Monday, January 6, 2014 10:12 AM

Answers

  • Hi,

    The WMIclass win32_product does only contain products that have been installed by Windows Installer. (http://msdn.microsoft.com/en-us/library/aa394378(v=vs.85).aspx)

    Therefore, when searching for windowsfeatures you should instead look in to the class win32_optionalfeature which contains features that have been added from server manager and so on. (http://msdn.microsoft.com/en-us/library/ee309383(v=vs.85).aspx)

    I would also recommend to use PowerShell instead of wmic to query for this, as below:

    #Either with get-wmiobject/GetCimInstance or get-windowsfeature (on a server) Get-WmiObject win32_optionalfeature -filter "caption LIKE '%.NET%'" | select Name,Caption,Installstate Get-WindowsFeature | Where-Object {$_.DisplayName -like "*.NET*"}

    #With wmic

    wmic /namespace:\\root\cimv2 path win32_optionalfeature where "caption like '%.NET%'"

    As you can see in my screenshots below, InstallState = 1 means the feature is installed when querying WMI, and 'Installed' is the one you're looking for when using Get-WindowsFeature.


    Microsoft Certified Trainer
    MCSE: Desktop, Server, Private Cloud, Messaging
    Blog: http://365lab.net




    • Edited by Johan DahlbomMVP Monday, January 6, 2014 11:05 AM added wmic
    • Proposed as answer by Johan DahlbomMVP Monday, January 6, 2014 1:08 PM
    • Marked as answer by nnagandla Tuesday, January 7, 2014 6:22 AM
    Monday, January 6, 2014 10:59 AM

All replies

  • Hi All
    • Merged by Susie Long Monday, January 6, 2014 12:14 PM duplication
    Monday, January 6, 2014 10:02 AM
  • Hi,

    The WMIclass win32_product does only contain products that have been installed by Windows Installer. (http://msdn.microsoft.com/en-us/library/aa394378(v=vs.85).aspx)

    Therefore, when searching for windowsfeatures you should instead look in to the class win32_optionalfeature which contains features that have been added from server manager and so on. (http://msdn.microsoft.com/en-us/library/ee309383(v=vs.85).aspx)

    I would also recommend to use PowerShell instead of wmic to query for this, as below:

    #Either with get-wmiobject/GetCimInstance or get-windowsfeature (on a server) Get-WmiObject win32_optionalfeature -filter "caption LIKE '%.NET%'" | select Name,Caption,Installstate Get-WindowsFeature | Where-Object {$_.DisplayName -like "*.NET*"}

    #With wmic

    wmic /namespace:\\root\cimv2 path win32_optionalfeature where "caption like '%.NET%'"

    As you can see in my screenshots below, InstallState = 1 means the feature is installed when querying WMI, and 'Installed' is the one you're looking for when using Get-WindowsFeature.


    Microsoft Certified Trainer
    MCSE: Desktop, Server, Private Cloud, Messaging
    Blog: http://365lab.net




    • Edited by Johan DahlbomMVP Monday, January 6, 2014 11:05 AM added wmic
    • Proposed as answer by Johan DahlbomMVP Monday, January 6, 2014 1:08 PM
    • Marked as answer by nnagandla Tuesday, January 7, 2014 6:22 AM
    Monday, January 6, 2014 10:59 AM
  • Thank you Johan!

    Tuesday, January 7, 2014 6:23 AM