locked
Remove multiple App-V packages via Powershell RRS feed

  • Question

  • Hi,

    I'd like to remove multiple packages from multiple servers.
    I got it working for 1 package, please advise what logic to use in order to change the script to remove multiple packages from multiple servers.
    F.e. via get-content c:\packages.txt which contains the packagenames and packageversions to remove.

    $servers = @("serverA","serverB")
    $packagename = 'packagename'
    $packageversion = 'packageversion"
    foreach ($server in $servers)
    {
        Invoke-Command -ScriptBlock { param($packagename,$packageversion) Remove-AppvClientPackage -Name $packagename -Version $packageversion } -ComputerName $server -argumentlist $packagename,$packageversion
    }

    Thanks!

    J.


    Jan Hoedt

    Tuesday, January 19, 2016 3:41 PM

Answers

All replies

  • You should first Unpublish the Packages before you remove them.

    A possible approach would be to load the data from the packages.txt in an Array (See this Post) and then add a new foreach loop inside your existing loop, that goes through this Array.

    Something like this, (untested!):

    $servers = @("serverA","serverB")
    #$packagename = 'packagename'
    #$packageversion = "packageversion"
    $packageData = Get-Content C:\packages.txt
    foreach ($server in $servers)
    {
        foreach ($data in $packageData) {
            $packagename = $data[0]
            $packageversion = $data[1]
            Invoke-Command -ScriptBlock { param($packagename,$packageversion) Unpublish-AppvClientPackage -Name $packagename -Version $packageversion Remove-AppvClientPackage -Name $packagename -Version $packageversion } -ComputerName $server -argumentlist $packagename,$packageversion
        }
    }


    Simon Dettling | msitproblog.com | @SimonDettling


    Tuesday, January 19, 2016 4:04 PM
    Moderator
  • If there are connection groups involved, you will want to include the logic to remove them as well before you remove the packages.
    Tuesday, January 19, 2016 9:00 PM
    Moderator
  • You can use the logic as said by App-V techies Simon and Cody. But prior to unpublish, you would need to stop the package.

     Stop-AppvClientPackage "name" -Global


    (Please click on "Vote as Helpful" and/or "Mark as Answer", if it has helped you.)

    app2pack.blogspot.com: app2pack.blogspot.com

    Wednesday, January 20, 2016 8:18 AM
  • Thanks for your input!

    One more remark: please see: https://social.technet.microsoft.com/Forums/en-US/e6422c48-ed62-45ac-86a0-46811559995c/appv-integration-error-not-integrated-for-the-user?forum=configmanagerapps

    We deploy the App-V-packages to users, not computers. Apparently the command to remove the App-V package is simply Remove-AppvClientPackage instead of get-appvclientpackage ... | stop etc

    Didn't fully test the remove-appvclientpackage (main goal is to cleanup some app-v packages which we fail  remove via SCCM).


    Jan Hoedt

    Wednesday, January 20, 2016 9:04 AM
  • Vigne, doesn't it make more sence to unpublish first? If you stop it and the user starts it, they get an error. Btw, if you do the remove, won't it do it all together (stop, unpublish, remove)?

    Jan Hoedt

    Wednesday, January 20, 2016 9:06 AM
  • Thanks Simon.
    I wonder how to format the txt-file since I have space in my packagenames. It doesn't work with single or double quotes.

    "My First package" "0.0.0.1"


    Jan Hoedt

    Wednesday, January 20, 2016 9:24 AM
  • @janhoedt,

    What if suppose the applications are in use? If you unpublish them, it will create a PendingTask entry in the registry and it would require to logoff/restart. When the user starts the application inbetween, it would fail as there is a pending task created. It's better to stop the application first before performing unpublish/remove. Kindly test the case if you have any doubt.

    Error screenshot below:

    Application in use and performed only remove-appvclientpackage


    (Please click on "Vote as Helpful" and/or "Mark as Answer", if it has helped you.)

    app2pack.blogspot.com: app2pack.blogspot.com

    Wednesday, January 20, 2016 10:03 AM
  • I wonder how to format the txt-file since I have space in my packagenames. It doesn't work with single or double quotes.

    Try to use a CSV File.

    Simon Dettling | msitproblog.com | @SimonDettling

    Wednesday, January 20, 2016 3:28 PM
    Moderator
    • Marked as answer by janhoedt Thursday, January 21, 2016 10:04 AM
    Thursday, January 21, 2016 10:04 AM
  • @janhoedt,

    Thanks for sharing the script.


    (Please click on Vote as Helpful and/or Mark as Answer, if it has helped you.)

    Want to add MVP behind my name

    app2pack.blogspot.com: app2pack.blogspot.com

    Thursday, January 21, 2016 10:31 AM