locked
Bulk remove group permission using powershell RRS feed

  • Question

  • Hi all, 

    I need some help with a script to bulk remove an AD group from all packages in appv 5 server on that group belongs to. I´m trying to use the "Entitlments" property of the package, but no luck. Here´s the script:

    $package = Get-AppvServerPackage -Name *MyAppvPackage*

    $users = $package.Entitlments

    foreach($user in $users){

    if ($user.GroupName -eq "DOMAIN\GROUP"){

    $package.Entitlments.Remove($user.GroupName)

    }

    }

    Some hints? Thank You.


    Alexandre Gomes

    Monday, June 2, 2014 6:39 PM

Answers

  • Well for the benefit of the next person looking to do this it looks like the best way to remove entitlements is to use Grant-AppvServerPackage. This Cmdlet actually overwrites all entitlements on an existing package, it does not just append a new group to the existing entitlements. Just read the existing entitlements of a package into an array then delete the ones you want to remove from the array before running the Cmdlet. Here is an example:

    Grant-AppvServerPackage -PackageID $Package.PackageGUID -VersionID $Package.VersionGUID -Groups $Groups


    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer".


    Monday, September 7, 2015 11:22 PM
  • set-appvclientpackage won't be availabe on the server ;-)

    Do you loop through all the packages?

    $packages = get-appvserverpackage -name *

    foreach ($package in $packages) {

    <do your stuff>

    }

    Not sure if set-appvserverpackage, $package.entitlement.remove() or grant-appvserverpackage would be the right command. (Not having a server on hand).

    In his book (http://www.lulu.com/shop/timothy-mangan-and-kate-mangan/powershell-with-app-v-5/paperback/product-21336355.html)http://www.lulu.com/shop/timothy-mangan-and-kate-mangan/powershell-with-app-v-5/paperback/product-21336355.html Tim writes that the package object doesn't have direct modification methods- 
    Therefor, my favorite would be grant-appvserverpackage


    Falko

    Twitter @kirk_tn   |   Blog kirxblog   |   Web kirx.org   |   Fireside appvbook.com

    Wednesday, June 4, 2014 11:39 AM
    Moderator

All replies

  • Hello,

    I would guess that you would need to use the set-appvclientpackage, but not sure if that is applicable in the above scenario


    Nicke Källén | The Knack| Twitter: @Znackattack

    Tuesday, June 3, 2014 3:36 PM
  • set-appvclientpackage won't be availabe on the server ;-)

    Do you loop through all the packages?

    $packages = get-appvserverpackage -name *

    foreach ($package in $packages) {

    <do your stuff>

    }

    Not sure if set-appvserverpackage, $package.entitlement.remove() or grant-appvserverpackage would be the right command. (Not having a server on hand).

    In his book (http://www.lulu.com/shop/timothy-mangan-and-kate-mangan/powershell-with-app-v-5/paperback/product-21336355.html)http://www.lulu.com/shop/timothy-mangan-and-kate-mangan/powershell-with-app-v-5/paperback/product-21336355.html Tim writes that the package object doesn't have direct modification methods- 
    Therefor, my favorite would be grant-appvserverpackage


    Falko

    Twitter @kirk_tn   |   Blog kirxblog   |   Web kirx.org   |   Fireside appvbook.com

    Wednesday, June 4, 2014 11:39 AM
    Moderator
  • Were you able to find the correct syntax to remove package entitlements?

    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer".

    Monday, September 7, 2015 2:22 AM
  • Well for the benefit of the next person looking to do this it looks like the best way to remove entitlements is to use Grant-AppvServerPackage. This Cmdlet actually overwrites all entitlements on an existing package, it does not just append a new group to the existing entitlements. Just read the existing entitlements of a package into an array then delete the ones you want to remove from the array before running the Cmdlet. Here is an example:

    Grant-AppvServerPackage -PackageID $Package.PackageGUID -VersionID $Package.VersionGUID -Groups $Groups


    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer".


    Monday, September 7, 2015 11:22 PM