Windows Vista Forums

how can I uninstall an application from multiple PC's?
  1. #1


    mmccormick Guest

    how can I uninstall an application from multiple PC's?

    Hi, I would like to uninstall an application from several PC's. I found the
    following
    script and it works great on the local PC, but I don't know how to add in a
    'foreach', collection of PC names, etc. so it will run on the rest of the
    PC's. Can anyone assist? Thanks!


    $product = Get-WmiObject -Class Win32_Product | Where-Object {
    $_.Name -like "Avaya PDS Agent"
    }

    $product.Uninstall()



      My System SpecsSystem Spec

  2. #2


    tojo2000 Guest

    Re: how can I uninstall an application from multiple PC's?

    On Dec 1, 9:23*am, mmccormick <mmccorm...@xxxxxx>
    wrote:

    > Hi, I would like to uninstall an application from several PC's. I found the
    > following
    > script and it works great on the local PC, but I don't know how to add ina
    > 'foreach', collection of PC names, etc. so it will run on the rest of the
    > PC's. Can anyone assist? Thanks!
    >
    > $product = Get-WmiObject -Class Win32_Product | Where-Object {
    > $_.Name -like "Avaya PDS Agent"
    >
    > }
    >
    > $product.Uninstall()
    Something like this should work to cycle through the computers, but
    keep in mind that many uninstallers require user interaction:

    foreach ($computer in $computers) {
    $product = Get-WmiObject -Class Win32_Product -ComputerName
    $computer |
    Where-Object {$_.Name -like "Avaya PDS Agent"}
    $product.Uninstall()
    }


      My System SpecsSystem Spec

  3. #3


    Brandon Shell [MVP] Guest

    Re: how can I uninstall an application from multiple PC's?

    I would use -filter to only return back the exact program. This is much faster
    than using where-object{} to filter

    NOTE: win32_product only returns products installed using the Windows Installer
    and is not installed by default on Windows 2000 or 2003 and only returns
    a limited amount of info on XP. See here for more info: http://msdn.microsoft.com/en-us/libr...78(VS.85).aspx


    Brandon Shell
    ---------------
    Blog: http://www.bsonposh.com/
    PSH Scripts Project: www.codeplex.com/psobject

    M> win32_product
    M>



      My System SpecsSystem Spec

  4. #4


    Sanderk Guest

    Re: how can I uninstall an application from multiple PC's?

    Hi,

    This request looks is a bit simular to a script i use, i modified it
    slightly;
    A Script that reads a text file with computernames, tests if a computer is
    "pingable", tries to uninstall the software. Log all results per computer to
    a text file

    -- cut -----

    function Remove-Apllication ($computer) {
    BEGIN {}
    PROCESS
    {
    $results = gwmi -query "SELECT * FROM Win32_PingStatus WHERE Address =
    '$computer'"
    if ($results.StatusCode -eq 0)
    {
    $ResultWMIQuery = Get-WMIObject -computerName $computer -query "select *
    from win32_Product where name='Avaya PDS Agent'"
    if ($ResultWMIQuery -ne $null)
    {
    $ResultWMIQuery.Uninstall()
    Write-Output "$computer Product uninstalled" | out-file
    "c:\Temp\ScriptOutPut.txt" -Append
    } else {
    Write-Output "$computer skipped (Product Not found)" | out-file
    "c:\Temp\ScriptOutPut.txt" -Append
    }
    } else {
    Write-Output "$computer skipped not Pingable" | out-file
    "c:\Temp\ScriptOutPut.txt" -Append
    }
    }
    END {}
    }

    gc c:\temp\computers.txt | %{Remove-Apllication $_}

    --- cut ----

    NOT FULLY TESTED

    Sander Klaassen


    "mmccormick" <mmccormick@xxxxxx> wrote in message
    news:6CFFFDC8-1270-4DDE-BDAC-DED14CD5F86C@xxxxxx

    > Hi, I would like to uninstall an application from several PC's. I found
    > the
    > following
    > script and it works great on the local PC, but I don't know how to add in
    > a
    > 'foreach', collection of PC names, etc. so it will run on the rest of the
    > PC's. Can anyone assist? Thanks!
    >
    >
    > $product = Get-WmiObject -Class Win32_Product | Where-Object {
    > $_.Name -like "Avaya PDS Agent"
    > }
    >
    > $product.Uninstall()

      My System SpecsSystem Spec

  5. #5


    mmccormick Guest

    RE: how can I uninstall an application from multiple PC's?

    Thank you very much for all the great info everyone. I went with Marco Shaw's
    advice and ran it this way:

    $comps="serverA","serverB"

    foreach($comp in $comps){
    $prod=gwmi -computer $comp win32_product -filter "name = 'Avaya PDS
    Agent'"
    $prod.uninstall()
    }
    It ran like a champ! Thanks Marco and everyone for all your help!



    "mmccormick" wrote:

    > Hi, I would like to uninstall an application from several PC's. I found the
    > following
    > script and it works great on the local PC, but I don't know how to add in a
    > 'foreach', collection of PC names, etc. so it will run on the rest of the
    > PC's. Can anyone assist? Thanks!
    >
    >
    > $product = Get-WmiObject -Class Win32_Product | Where-Object {
    > $_.Name -like "Avaya PDS Agent"
    > }
    >
    > $product.Uninstall()

      My System SpecsSystem Spec

how can I uninstall an application from multiple PC's? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Uninstall application script Richard Mueller [MVP] VB Script 1 04 Jun 2009
How to uninstall stubborn (or corrupt) application? occam Vista General 3 02 Mar 2008
Cannot uninstall any application thru Programs and Features of Vis Rani Vista installation & setup 5 19 Jan 2008
Uninstall an application using Powershell y.bobzhang PowerShell 1 05 Oct 2007
How to uninstall a Windows Media Center application in Vista? M. Krantz Vista installation & setup 0 06 Mar 2007