How to use PowerShell of XenDesktop to do Update Machines-- qualified Pool
Recently, a customer thought that after updating the Windows 7 master,
Can update automatically every month without moving to Studio.
Therefore, a Powershell is written for this requirement and incorporated into the work schedule of Windows 2012.
First clarify the basic environment
Hypervisor:XenServer 6.5
OS:Windows 2012 R2
Desktop version: Xendesktop7.6.3
$Today=Get-Date-UFormat% Y%m%d_%H%M%S # # set Snapshot date
New-HypVMSnapshot-AdminAddress "ddc.citrix.com:80"-LiteralPath "XDHyp:\ HostingUnits\ dd\ Windows 7 test.vm"-SnapshotName "Citrix_$Today" # # VM running Snapshot
$ProvSchemeName = "TESTSCRIPTS" # # you need to define the name on your Machin Catalogs to do update
$Snapshot = "Citrix_$Today"
Start-Sleep-s 30 # # if we do not stop 30sec, our environment will cause problems to the number of people running below.
$VM = get-childitem-adminaddress "ddc.citrix.com:80"XDHyp:\ HostingUnits\ dd\" | where-object {$_ .ObjectType-eq 'VM'-and $_ .PSChildName-like' Windows 7 test.vm'} # # grab the VM path in Hypervisor for master update
$VMSnapshot = get-childitem-adminaddress "ddc.citrix.com:80" $VM.FullPath-Recurse-Include * .snapshot # # grab the Snapshot path 1 in the update VM machine
$TargetSnapshot = $VMSnapshot | Where-Object {$_ .FullName-eq "$snapshot.snapshot"} # # grab the Snapshot path 2 in the update VM machine
Set-ProvSchemeMetadata-AdminAddress "ddc.citrix.com:80"-Name "ImageManagementPrep_DoImagePreparation"-ProvisioningSchemeName "TESTSCRIPTS"-Value "True" # # prepare for updated process
Publish-provMasterVMImage-provisioningSchemeName $ProvSchemeName-MasterImageVM $TargetSnapshot.fullpath-AdminAddress "ddc.citrix.com:80"-RunAsynchronously # # start of execution update
Start-BrokerNaturalRebootCycle-AdminAddress "ddc.citrix.com:80"-InputObject @ ("TESTSCRIPTS") # # reopen directly after update
Refer to the web address:
Http://stealthpuppy.com/xendesktop-update-mcs-machine-catalog-powershell/