Horizon View – view pool automation Part1

Objective: In this blog, we will automate all the possibilities of Horizon view implementation. The below mentioned commands are tested in development prior to production release..

Scenario: The corporate Desktop and application team coordinated to obtain base VM with required configurations. As a View admin, we need to locate VMs into appropriate cluster (10 VMs into one cluster) considering design. Also, to setup Automated linked clone view pool, we need to assign vlan, obtain snapshot and subsequent view pool creation should be automated.

Steps:

  1. Locate Base VMs into Appropriate cluster / Host
  2. Assign relevant VLAN to located Base VMs considered as Golden Image
  3. Create snapshot for Base VMs
  4. Create View Pool
  5. Entitlement of users

1.       Locate Base VMs into Appropriate cluster / Host

Get-HardDisk -VM ‘Base1’

move-vm  ‘Base1’ -Destination esxi01 -datastore PRD-VDI -diskstorageformat Thin

Get-HardDisk -VM ‘Base1’’

2.       Assign relevant VLAN to located Base VMs considered as Golden Image

$vms1 = Import-CSV C:\SCRIPT\VDNet-01.csv

$vms1

foreach ($vm in $vms1){

Get-VM $vm.name | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName VDINet-01 -Confirm:$false

}

3.       Create snapshot for Base VMs

cls

$vms = Import-CSV C:\SCRIPT\VIEW\selvavms.csv

foreach ($vm in $vms){

$base = $vm.name

$y=[string]::Join(“-“,$base ,”A”)

New-Snapshot -VM $base -Name $y

}

4.       Create View Pool

$vms = Import-CSV C:\Scriptview\selvavms.csv

foreach ($vm in $vms){

$base = $vm.name

$snapnm = $vm.snap

$user=’-s.vdi.build’

$poolid =$vm.poolidd

$pooldec = $vm.dispname

$pooldec

$ds = $vm.datastore

$npx = “$base{n:fixed=2}”

$parenvm = “/xxxx/vm/APAC/BASE/$base”

$ou = “OU=VDI,OU=Virtuals,OU=Workstations,OU=VDI01”

$rs = $vm.res+”/Resources”

$rs

get-viewvc -servername Vcen01.vra.local | get-composerdomain -user $user | Get-composerdomain -domain vra.local | Add-AutomaticLinkedCLonePool -pool_id $poolid -displayName $pooldec -namePrefix $npx -parentVMPath $parenvm -parentSnapshotPath  $snapnm -vmFolderPath /xxxx/vm/xxx -resourcePoolPath $rs -datastoreSpecs $ds -organizationalUnit $ou -minimumcount 2 -maximumCount 5 -headroomcount 2 -powerpolicy Alwayson

}

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: