Answered by:
Bulk remove group permission using powershell

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".
- Proposed as answer by David Kozera Monday, September 7, 2015 11:22 PM
- Edited by David Kozera Monday, September 7, 2015 11:23 PM
- Marked as answer by Aaron.ParkerModerator Tuesday, September 8, 2015 12:46 AM
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-appvserverpackageFalko
Twitter @kirk_tn | Blog kirxblog | Web kirx.org | Fireside appvbook.com
- Marked as answer by Brandon RecordsModerator Wednesday, June 11, 2014 4:00 PM
Wednesday, June 4, 2014 11:39 AMModerator
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-appvserverpackageFalko
Twitter @kirk_tn | Blog kirxblog | Web kirx.org | Fireside appvbook.com
- Marked as answer by Brandon RecordsModerator Wednesday, June 11, 2014 4:00 PM
Wednesday, June 4, 2014 11:39 AMModerator -
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".
- Proposed as answer by David Kozera Monday, September 7, 2015 11:22 PM
- Edited by David Kozera Monday, September 7, 2015 11:23 PM
- Marked as answer by Aaron.ParkerModerator Tuesday, September 8, 2015 12:46 AM
Monday, September 7, 2015 11:22 PM