Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

win32_product uninstall method

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-11-2007   #1 (permalink)
Bayer, David
Guest


 

win32_product uninstall method

I am trying to learn how to call WMI methods in PowerShell, in this case the
win32_product Uninstall method. So far, none of the information I've found
has worked. I've tried 3 methods (I have substituted programname for the
desired program):
1)
$pc = Get-WmiObject -query "SELECT * FROM Meta_Class WHERE
__Class='Win32_Product'"
$pc.uninstall("programname")

this one returns the error "Method invocation failed because
[System.Management.ManagementClass#ROOT\cimv2\Win32_Product] doesn't contain
a method named 'uninstall'.

2)
various iterations of the script found here:
Getting the class, not instances, with Get-WMIObject?

all attempts with this also returned something along the lines of the error
above, regardless of whether I tried the install or uninstall method.

3)
$prog = Get-WmiObject -class win32_product -computername $cmp | Where-Object
{ $_.name -match "programname" }
$prog.uninstall

but this returns
MemberType : Method
OverloadDefinitions : {System.Management.ManagementBaseObject Uninstall()}
TypeNameOfValue : System.Management.Automation.PSMethod
Value : System.Management.ManagementBaseObject Uninstall()
Name : Uninstall
IsInstance : True


Any ideas?

Thanks
Dav


My System SpecsSystem Spec
Old 07-11-2007   #2 (permalink)
dreeschkind
Guest


 

RE: win32_product uninstall method

Try to using $prog.uninstall() to invoke the method.

--
greetings
dreeschkind


"Bayer, David" wrote:

> I am trying to learn how to call WMI methods in PowerShell, in this case the
> win32_product Uninstall method. So far, none of the information I've found
> has worked. I've tried 3 methods (I have substituted programname for the
> desired program):
> 1)
> $pc = Get-WmiObject -query "SELECT * FROM Meta_Class WHERE
> __Class='Win32_Product'"
> $pc.uninstall("programname")
>
> this one returns the error "Method invocation failed because
> [System.Management.ManagementClass#ROOT\cimv2\Win32_Product] doesn't contain
> a method named 'uninstall'.
>
> 2)
> various iterations of the script found here:
> Getting the class, not instances, with Get-WMIObject?
>
> all attempts with this also returned something along the lines of the error
> above, regardless of whether I tried the install or uninstall method.
>
> 3)
> $prog = Get-WmiObject -class win32_product -computername $cmp | Where-Object
> { $_.name -match "programname" }
> $prog.uninstall
>
> but this returns
> MemberType : Method
> OverloadDefinitions : {System.Management.ManagementBaseObject Uninstall()}
> TypeNameOfValue : System.Management.Automation.PSMethod
> Value : System.Management.ManagementBaseObject Uninstall()
> Name : Uninstall
> IsInstance : True
>
>
> Any ideas?
>
> Thanks
> Dav
>
>

My System SpecsSystem Spec
Old 07-11-2007   #3 (permalink)
Bayer, David
Guest


 

Re: win32_product uninstall method

Doh! Amazing the difference that a little syntax will make... It's working
now - Thanks!

Dav

"dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message
news:4CA50EFC-780C-443C-B839-79231A580EA1@microsoft.com...
> Try to using $prog.uninstall() to invoke the method.
>
> --
> greetings
> dreeschkind
>
>
> "Bayer, David" wrote:
>
>> I am trying to learn how to call WMI methods in PowerShell, in this case
>> the
>> win32_product Uninstall method. So far, none of the information I've
>> found
>> has worked. I've tried 3 methods (I have substituted programname for the
>> desired program):
>> 1)
>> $pc = Get-WmiObject -query "SELECT * FROM Meta_Class WHERE
>> __Class='Win32_Product'"
>> $pc.uninstall("programname")
>>
>> this one returns the error "Method invocation failed because
>> [System.Management.ManagementClass#ROOT\cimv2\Win32_Product] doesn't
>> contain
>> a method named 'uninstall'.
>>
>> 2)
>> various iterations of the script found here:
>> Getting the class, not instances, with Get-WMIObject?
>>
>> all attempts with this also returned something along the lines of the
>> error
>> above, regardless of whether I tried the install or uninstall method.
>>
>> 3)
>> $prog = Get-WmiObject -class win32_product -computername $cmp |
>> Where-Object
>> { $_.name -match "programname" }
>> $prog.uninstall
>>
>> but this returns
>> MemberType : Method
>> OverloadDefinitions : {System.Management.ManagementBaseObject
>> Uninstall()}
>> TypeNameOfValue : System.Management.Automation.PSMethod
>> Value : System.Management.ManagementBaseObject Uninstall()
>> Name : Uninstall
>> IsInstance : True
>>
>>
>> Any ideas?
>>
>> Thanks
>> Dav
>>
>>


My System SpecsSystem Spec
Closed Thread
Update your Vista Drivers Update Your Drivers Now!!

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Method invocation failed because [System.String] doesn't contain a method B Williams PowerShell 0 03-31-2008 06:00 PM
Create log file using Win32_Product Install() method Flea# PowerShell 1 01-16-2008 04:05 PM
win32_product not valid Frank PowerShell 3 05-12-2007 05:10 PM
Get-WmiObject Win32_Product Keith Hill PowerShell 6 02-26-2007 02:21 PM
WMI Object Win32_Product and Pipeline woes machone3720 PowerShell 3 08-29-2006 09:05 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51