Author Posts

August 2, 2018 at 7:26 am

Hello,

I took a script from SpiceWorks , but the program can uninstall one app .

I want uninstall SAP Crystal reports but when i list with Win32 Products , i have many app like crystalreports.cpp .

My question is : how to adapt the script to uninstall all app like crystalreports .

Ps Script doesnt work with this :

$machineName = Read-host "Enter a Machine Name:"
#$userName = Read-Host "Enter your admin account:"

$app = Get-WmiObject -Class Win32_Product -computerName $machineName -impersonation Impersonate | Where-Object {($_.Vendor -Like "SAP*") -and ($_.Name -Like "crystalreports*")}
$app.Uninstall()

Loop is missing but i dont know how to do .

Thanks and excuse me for my bad english ( i'm french)

August 2, 2018 at 9:08 am

Your script looks ok except for the last line. Try the following

$app | foreach-object {$_.uninstall()}

Note, I am not in front of a computer to test.

August 2, 2018 at 9:20 am

Thanks,

I will say you if it's okay .

August 2, 2018 at 9:29 am

Thanks a lot , it's working .