Uninstall programs remotely

Welcome Forums General PowerShell Q&A Uninstall programs remotely

This topic contains 3 replies, has 2 voices, and was last updated by

 
Participant
3 months, 1 week ago.

  • Author
    Posts
  • #105785

    Participant
    Points: 0
    Rank: Member

    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)

  • #105794

    Participant
    Points: 22
    Rank: Member

    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.

    • #105797

      Participant
      Points: 0
      Rank: Member

      Thanks,

      I will say you if it's okay .

  • #105800

    Participant
    Points: 0
    Rank: Member

    Thanks a lot , it's working .

The topic ‘Uninstall programs remotely’ is closed to new replies.