Skip to main content

Set Horizon View Pool Entitlements Using Powershell Script

If you have a Horizon View environment were you need assign a large number of users or have a high turn over rate in some of your pools you will not want to use the GUI to do this task. As we all know using the GUI takes a very long time to do this task.
Requirements needed to run this script:
  • Horizon View Environment must be running version 7.0.2 or newer
  • PowerCLI
  • Advanced Functions (Hv.Helper) Module - (Download)
  • Text file with user names to be added to the pool
Below is the script to do this task.

1:  # =========================================================================================================  
2:  #   
3:  # NAME: HorizonView_New_Entitlement.ps1  
4:  #   
5:  # AUTHOR: Troy Peters  
6:  #   
7:  # This will set a new user entitlement for a desktop pool  
8:  #  
9:  #  
10:  # =========================================================================================================  
11:  # ======================== Import Modules ========================  
12:  Get-Module -Name VMware.HV.Helper -ListAvailable | Import-Module -Force  
13:  Get-Module –Name VMware.*View –ListAvailable | Import-Module -Force  
14:  # ================================================================  
15:  # ======================== Set Variables ========================  
16:  $HVServerName = "vcs01.corp.local" #set to the horizon view connection server you want to use  
17:  $Domain = "@corp.local" #Set to the doamin name  
18:  # --- Get Horizon Pool you want to add user to ---  
19:  $PoolName = Read-Host "Enter the Pool name you want to assigne user to."  
20:  # ================================================================  
21:  # --- Connect to Horizon View and get prompted for credentials ---  
22:  Connect-HVServer -Server $HVServerName  
23:  # --- Load list of Users ---  
24:  $file = "C:\temp\Users.txt" #Text file only needs the user name in it  
25:  $Users = Get-Content $file  
26:  #Loop function to assigne each user in text file to desktop pool  
27:  ForEach ($User in $Users)  
28:    {  
29:            #Set Entitlement for user for one desktop pool  
30:            New-HVEntitlement -User ($User + $Domain) -ResourceName $PoolName -Confirm:$false  
31:    }  
32:  # --- Disconnect from Current Horizon Connection Server ---  
33:  Disconnect-HVServer -Server $HVServerName  

Comments