Windows Server TechCenter > Windows Server Forums > Windows PowerShell > get-wmiobject against 2003 server fails
Ask a questionAsk a question
 

Questionget-wmiobject against 2003 server fails

  • Friday, November 16, 2007 1:44 AMpdirt Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    I am succesfully running a Pshell script against remote machines using get-wmiobject, and it works well against all win32 so far,except windows 2003.

     

     

    It returns this

    Get-WmiObject : Invalid class
    At C:\Users\Administrator\Desktop\remcoresep.ps1:36 char:18
    + ($p=Get-WmiObject  <<<< win32_product -computername $rc -credential $cred | Where-Object {$_.Name -match "Software"})

     

     

    Is Win32_product class not available from WMI on 2003?

     

    Thanks!

     

    -p

All Replies

  • Tuesday, November 20, 2007 9:04 PMDesmond LeeMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Could you please post the entire code that you used? It could be as simple as typo error that caused the command to fail.

     

     

  • Wednesday, November 21, 2007 6:14 AMpdirt Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Sure, but, as stated this same code works fine pointing to XP, 2k, and 2k8...

     

    the code is in the error message as well, but here ya go:

     

    <snip>

    if

    ($p=Get-WmiObject win32_product -computername $rc -credential $cred | Where-Object {$_.Name -match "Software"})

    {

    write-host

    write-host Software products intsalled: -backgroundcolor yellow -foregroundcolor black

    write-host

    $p

    </snip>

     

    The word software is used in place an acutal app I am working on... fyi.

  • Saturday, November 24, 2007 1:29 PMDesmond LeeMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello,

     

    There is no Win32_product class in Windows Server 2003 but it exists in Windows XP SP2. That is to say, the WMI implementation is not necessary uniform across the platforms, unfortunately.

     

    You can verify this fact using the following:

     

    PS C:\> Get-WmiObject -list | Where-Object { $_ -ilike "*product*" } | Sort-Object | Format-List name

     

    # Result from Win Server 2003

    Name : CIM_CompatibleProduct

    Name : CIM_FRUIncludesProduct

    Name : CIM_Product

    Name : CIM_ProductFRU

    Name : CIM_ProductParentChild

    Name : CIM_ProductPhysicalElements

    Name : CIM_ProductProductDependency

    Name : CIM_ProductSoftwareFeatures

    Name : CIM_ProductSupport

    Name : Win32_ComputerSystemProduct

    Name : Win32_ComputerSystemWindowsProductActivationSetting

    Name : Win32_WindowsProductActivation

     

    # Result from Win XP SP2

    Name : CIM_CompatibleProduct

    Name : CIM_FRUIncludesProduct

    Name : CIM_Product

    Name : CIM_ProductFRU

    Name : CIM_ProductParentChild

    Name : CIM_ProductPhysicalElements

    Name : CIM_ProductProductDependency

    Name : CIM_ProductSoftwareFeatures

    Name : CIM_ProductSupport

    Name : Win32_ComputerSystemProduct

    Name : Win32_ComputerSystemWindowsProductActivationSetting

    Name : Win32_Product

    Name : Win32_ProductCheck

    Name : Win32_ProductResource

    Name : Win32_ProductSoftwareFeatures

    Name : Win32_WindowsProductActivation

     

     

    Do share with us if this helps. Thanks!

     

  • Friday, November 30, 2007 3:11 PMAndrey Nepomnyaschih Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You can install the class in question:

    1. In Add or Remove Programs, click Add/Remove Windows Components.
    2. In the Windows Components Wizard, select Management and Monitoring Tools and then click Details.
    3. In the Management and Monitoring Tools dialog box, select WMI Windows Installer Provider and then click OK.
    4. Click Next.
  • Saturday, December 01, 2007 6:06 PMpdirt Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Killer!  I will give that a go... Thanks all!

     

    -p

  • Monday, December 03, 2007 8:19 PMpdirt Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    This gets around the error regarding the class being invalid, but it returns no data.  When I run wmic locally on the 2k3 server, and run the product query it returns no instances... so that's where I am now.. looking into that... thanks for the help, however!

     

     

  • Monday, December 03, 2007 8:47 PMAndrey Nepomnyaschih Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    That sounds way too strange to me. Can you look around for any hint in event viewer or WMI logs?

     

    I even got my hands on a Windows 2003 without this provider installed. vmic was not compaining about invalid class at first, but afterwards it displayed the list of installed products.

  • Wednesday, July 09, 2008 7:01 AMDennydd Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I ran into this problem. Win32_product class is found in Windows XP but not in Windows Server 2003.
    www.infotechguyz.com - Server 2008, Exchange 2007 Tutorials
  • Tuesday, August 12, 2008 11:12 AMpkr2000 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I believe you have to make sure WMI is installed in 2003 it's optional.


    http://pdkm.spaces.live.com/