Connect to a Random VMware View Desktop Pool Using PowerCLI

recreation_pool_aerobicsLast week I had a conversation with one of my team mates  We were asked to provide a way for a VDI user to connect to a random VMware View desktop (floating) pool automatically each time a desktop is needed.

I’ve created a PowerCLI script which will provide a way for a random pool selection from the user’s pool assignment.

The only prerequisite for this to work is that the View administrator will grant user pool permissions up-front.

[sourcecode language=”powershell”]
#Random View Desktop Pool Connection
#Created for:
#Created by: Lior Kamrat
#Created on: 16/04/2013

#Map VMware View Connection Server and desktop pools names
$View_Connection_Server_Address = "Enter VMware View Connection Server"

#List desktop pools and select a random pool from the list
$Desktop_Pool_1 = "Pool Name"
$Desktop_Pool_2 = "Pool Name"
$Desktop_Pool_3 = "Pool Name"
$Selected_Pool = @($Desktop_Pool_1, $Desktop_Pool_2, $Desktop_Pool_3) | Get-Random

#Run VMware View Client with the following parameters:
# 1. VMware View Client Location
# 2. Login as current user (true \ false)
# 3. VMware View Connection Server Address
# 4. Desktop Pool Name
# 5. Session Interaction (interactive \ noninteractive)

& "C:\Program Files\VMware\VMware View\Client\bin\wswc.exe" -loginascurrentuser true, -serverurl $View_Connection_Server_Address, -desktopname $Selected_Pool, -interactive

Be the first to comment

Leave a Reply