View-PowerCLI

Part 1: Horizon View – view pool creation 

Part 2: Horizon View Pool Day2 operations

 

Part 1: Horizon View – view pool creation 

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

}

 

Part 2: Horizon View Pool Day2 operations

Welcome backup to Tech-Ops Blogs. This post will explain to handle day to day operations of Horizon View pools using Command line.

How can we reduce no of desktops in the view pool?

update-AutomaticLinkedClonePool -Pool_id “Pool1” -MinimumCount 1 -MaximumCount 1 -headroomCount 1

update-AutomaticLinkedClonePool -Pool_id “Pool2” -MinimumCount 1 -MaximumCount 1 -headroomCount 1

How can we Disable View pool provision and view deskop pools?

update-AutomaticLinkedClonePool -Pool_id “Pool1” -Disabled 1 -IsProvisioningEnabled 0

update-AutomaticLinkedClonePool -Pool_id “Pool2” -Disabled 1 -IsProvisioningEnabled 0

How can we Enable View pool provision and view deskop pools?

update-AutomaticLinkedClonePool -Pool_id “Pool1” -Disabled 0 -IsProvisioningEnabled 1

update-AutomaticLinkedClonePool -Pool_id “Pool2” -Disabled 0 -IsProvisioningEnabled 1

How to update Update Linked clone pool datastore?

update-AutomaticLinkedClonePool -Pool_id “Pool1” -DatastoreSpecs aaa/host/Datastorename

update-AutomaticLinkedClonePool -Pool_id “Pool2” -aaa/host/Datastorename

How to change the snapshot of View pool?

Update-AutomaticLinkedClonePool -pool_id “Pool1” -parentVMPath /vc/vm/BASE/vm -parentSnapshotPath /3360339A1 -ErrorAction “stop”

Finally, yes. How To do Recompose with new snapshot:

Update-AutomaticLinkedClonePool -pool_id “pool1” -parentVMPath /location of vm -parentSnapshotPath /602G9A1 -ErrorAction “stop”

Get-Desktopvm -pool_id pool1 | Send-LinkedCloneRecompose  -parentVMPath /vm/BASE/vm1 -parentSnapshotPath /vm1 -schedule ((get-date).addminutes(2)) -forceLogoff:$true -stopOnError:$true -ErrorAction “stop”

%d bloggers like this: