|
Newbie: Help me OUT Hi All,
I have around 200 computers from which i need to unistall SQL SERVER 2000.
My idea is to list the computers in a CSV file, import the CSV into
powershell and apply wmi Methods to Uninstall the Software.
This is what i want to do,
Computer, Status
a-b-1,
a-b-2,
a-b-3,
..
..
..
I tried to scribble some script with my limited knowledge and produced the
following piece of PS code.
$a = Import-Csv c:\sql.csv |
$b = $a |foreach { get-WmiObject win32_product -computer $_.computer |
select name}
$c = $b | where {$_.name -match 'SQL Server'}
foreach ($d in $c) { $d.Invokemethod("Uninstall", 1) }
I know there are some bugs in this, which i'm trying to resolve.
But i dont know how to get the following output
Computer, Status
a-b-1, Success
a-b-2, Failed
a-b-3, Errors
..
..
..
Not sure how to acheive this, Guess we can reture a value from Uninstall and
using the return value i can write success or failure to the CSV, but not
sure how to put this to status column of CSV file.
Also i want to run this script with admin previledges from a server at
scheduled period, Is there any way to embedd credentials encrypted into the
script?
Guess someone can help me!! Thanks in advance. |