View Single Post
Old 08-26-2006   #2 (permalink)
Jeffrey Snover [MSFT]


 
 

Re: Newbie: Help me OUT

I'm not going to test this on my machine to see if i got the code correct so
there might be errors :-).
That is the downside of direct .NET access vs Cmdlet. If it was a Cmdlet,
you could just type -WHATIF and things would be great.

$list= import-csv c:\sql.csv
foreach ($entry in $list)
{
$prod = Get-WmiObject Win32_Product -computer $a.Computer |where
{$_.name -match "SQL Server"}
$status = $prod.InvokeMethod("Uninstall",1)
switch ($status.ReturnValue)
{
0 {$entry.Status = "Success"}
2147549445 {$entry.Status = "RPC Server Fault"}
default {$entry.Status = $status.ReturnValue}
}
}
$list |export-csv c:\sql.csv

The link below documents the returnValue values:
http://msdn.microsoft.com/library/de...32_product.asp
--
Jeffrey Snover [MSFT]
Windows PowerShell/Aspen Architect
Microsoft Corporation
This posting is provided "AS IS" with no warranties, no confers rights.
Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scr.../hubs/msh.mspx


My System SpecsSystem Spec