View-PowerCLI

In this blog, we will automate few vSphere related activities dependent tasks for Horizon view pool creation. Ex, Snapshot creation, locating VM to appropriate ESXi etc.

  1. Horizon View pool creation
    1. Locate Base VMs into Appropriate cluster / Host
    2. Assign VLAN to located Base VMs
    3. Create snapshot for Base VMs
    4. Create View Pool
    5. View Pool Entitlment
  2. Horizon View Operations and inventory preparation
  3. GUI Development in order to obtain the usage report as shown below
  1. Horizon View pool Creation

As a View admin, we need to locate VMs into appropriate cluster (10 VMs into one cluster), assign vlan, create snapshot and subsequent view pool creation.

Steps:

  • 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’

  • Assign VLAN to located Base VMs

$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
}

  • Create snapshot for Base VMs

$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
}

  • 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
}

  • Entitlement of users

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: