VMware View – Adding & Removing Pool Entitlements Via Scheduled Tasks

I recently had a requirement for a customer to automatically add and remove user entitlements on VMware View 5.0 virtual desktop pools. While this can be achieved through View PowerCLI, the customer needed to query Active Directory to obtain a security group and then apply or remove this group from a pool. The issue with View PowerCLI in 5.0 is that the PowerShell aspect is a snap-in and not a module. Due this, a simple script calling both the Active Directory and View PowerCLI modules is not possible. To work around the limitation I have written the following scripts to add and remove pool entitlements using Active Directory groups.

Add Entitlement PowerShell Script: Download

Remove Entitlement PowerShell Script: Download

There are a two environment specific variables that need changing in each of the .PS1 files, these are the following:

 Get-ADGroup“Users” | Add-PoolEntitlement -pool_id “Test”

 Get-ADGroup“Users” | Remove-PoolEntitlement -pool_id “Test”

Where “Users” is the name of the Active Directory security group you wish to add or remove from a pool, and where “Test” is the name of the pool in which you want to apply or remove an entitlement. To run the scripts as scheduled tasks, place each script on one of your VMware View Connection Servers, in a directory such as C:\ViewScripts. Proceed and create a new basic task in the Windows Task Scheduler and specify the required bat file as available for download below.

Add Entitlement Bat File: Download

Remove Entitlement Bat File: Download

The created bat files essentially call powershell.exe and then execute the required .PS1 file. A specific “-File” parameter in the bat file needs amending for your environment, as detailed below.

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file “C:\ViewScripts\AddEntitlement.ps1″

The process is now complete.