Deal of the Day

Home » Main » Manning Forums » 2006 » Windows PowerShell in Action

Thread: WMI example for add/remove programs does not work ?

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Pages: 1 - Last Post: Jun 29, 2007 5:14 AM by: /\/\o\/\/
amol_deshpande

Posts: 6
From: San Francisco
Registered: 11/27/06
WMI example for add/remove programs does not work ?
Posted: Dec 4, 2006 6:02 PM
  Click to reply to this thread Reply

PS D:\mydir> get-wmiobject -class "win32reg_addremoveprograms" -namespace "root\cimv2" |select-object -property DisplayName

results in:

Get-WmiObject : Invalid class
At line:1 char:14
+ get-wmiobject <<<< -class "win32reg_addremoveprograms" -namespace "root\cimv
2" |select-object -property DisplayName
PS D:\prime\BuildServerScripts>

murk_johansen

Posts: 1
From: Portland
Registered: 3/31/07
Re: WMI example for add/remove programs does not work ?
Posted: Mar 31, 2007 3:07 PM   in response to: amol_deshpande in response to: amol_deshpande
  Click to reply to this thread Reply

Yeah, I get the same error.

secretGeek

Posts: 2
From: Australia
Registered: 4/10/07
Re: WMI example for add/remove programs does not work ?
Posted: Apr 10, 2007 7:26 AM   in response to: murk_johansen in response to: murk_johansen
  Click to reply to this thread Reply

i can find 3 class in that namespace that contain the word 'add' -- and none of them is the one we're after.

get-wmiobject -namespace "root\CIMV2" -list | where {$_.__CLASS -like '*add*'}

returns
Win32_DeviceMemoryAddress
Win32_PerfRawData_PerfProc_ProcessAd...
Win32_PerfFormattedData_PerfProc_Pro...

but no 'addremoveprograms'

it's fun to tinker though ;-)

hrh1818

Posts: 1
From: USA
Registered: 6/26/07
Re: WMI example for add/remove programs does not work ?
Posted: Jun 26, 2007 9:51 AM   in response to: amol_deshpande in response to: amol_deshpande
  Click to reply to this thread Reply

According to a posting in the microsoft.public.windows.powershell users group you need System Management Server (SMS) software from Microsoft to use the Win32_addremomeprograms class. I found some information on SMS by doing a Google search. However the instruction for installing the sofwate were confusing so I didn't waste any more time trying to install SMS server and client software.

Howard

marco.shaw

Posts: 24
From: Canada
Registered: 3/5/07
Re: WMI example for add/remove programs does not work ?
Posted: Jun 28, 2007 2:20 PM   in response to: hrh1818 in response to: hrh1818
  Click to reply to this thread Reply

/\/\o\/\/ posted in the PowerShell newsgroup on how to create that WMI "class" manually.

/\/\o\/\/

Posts: 5
From: The Netherlands
Registered: 9/20/06
Re: WMI example for add/remove programs does not work ?
Posted: Jun 29, 2007 5:14 AM   in response to: marco.shaw in response to: marco.shaw
  Click to reply to this thread Reply

F.Y.C.

Here is the code to create the WMI class manualy as posted in the NG

I changed classname to win32_reg_ARP for this example ( as I have SMS ;-) ) :

###

set-content RegProgs.mof @'
#pragma namespace("\\\\.\\root\\cimv2")
instance of __Win32Provider as $Instprov
{
Name ="RegProv" ;
ClsID = "{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}" ;
};
instance of __InstanceProviderRegistration
{
Provider =$InstProv;
SupportsPut =TRUE;
SupportsGet =TRUE;
SupportsDelete =FALSE;
SupportsEnumeration = TRUE;
};



[dynamic, provider("RegProv"),
ProviderClsid("{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}"),ClassContext("local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")]
class win32reg_ARP
{
[key]
string ProdID;
[PropertyContext("DisplayName")]
string DisplayName;
[PropertyContext("Publisher")]
string Publisher;
[PropertyContext("DisplayVersion")]
string Version;
};

'@

mofcomp.exe RegProgs.mof

get-wmiobject Win32reg_arp

###

Enjoy,
Greetings /\/\o\/\/
http://thePowerShellGuy.com

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor