get-wmiobject against 2003 server fails
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
Could you please post the entire code that you used? It could be as simple as typo error that caused the command to fail.
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 blackwrite-host
$p
</snip>
The word software is used in place an acutal app I am working on... fyi.
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!
- 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. Killer! I will give that a go... Thanks all!
-p
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!
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.
- 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 - I believe you have to make sure WMI is installed in 2003 it's optional.
http://pdkm.spaces.live.com/