Uninstall programs remotely


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*”)}

Loop is missing but i dont know how to do .

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

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.


I will say you if it’s okay .

Thanks a lot , it’s working .