标签:windows citrix update powershell
最近某個客戶為了能夠在更新Windows 7母版之後,
在不動到Studio的狀況下,每月能夠自動更新,
因此為了這個需求寫了一個Powershell,並套進在Windows 2012的工作排成之中。
先說明基本環境
Hypervisor:XenServer 6.5
OS:Windows 2012 R2
虛擬桌面版本:Xendesktop7.6.3
$Today=Get-Date -UFormat %Y%m%d_%H%M%S ##設定Snapshot日期
New-HypVMSnapshot -AdminAddress "ddc.citrix.com:80" -LiteralPath "XDHyp:\HostingUnits\dd\Windows 7 test.vm" -SnapshotName "Citrix_$Today" ##執行Snapshot的VM
$ProvSchemeName = "TESTSCRIPTS" ##需要針對你的Machin Catalogs上的名稱定義來做update
$Snapshot = "Citrix_$Today"
Start-Sleep -s 30 ##如果不停止30sec,我這邊的環境會發生帶到兩筆路徑到待會下面的執行變數之中。
$VM = get-childitem -adminaddress "ddc.citrix.com:80" "XDHyp:\HostingUnits\dd\" | where-object {$_.ObjectType -eq ‘VM‘ -and $_.PSChildName -like ‘Windows 7 test.vm‘} ##抓取Hypervisor中要做母版更新的VM路徑
$VMSnapshot = get-childitem -adminaddress "ddc.citrix.com:80" $VM.FullPath -Recurse -Include *.snapshot ##抓取更新VM機器之中的Snapshot路徑1
$TargetSnapshot = $VMSnapshot | Where-Object {$_.FullName -eq "$snapshot.snapshot"} ##抓取更新VM機器之中的Snapshot路徑2
Set-ProvSchemeMetadata -AdminAddress "ddc.citrix.com:80" -Name "ImageManagementPrep_DoImagePreparation" -ProvisioningSchemeName "TESTSCRIPTS" -Value "True" ##準備更新的process
publish-provMasterVMImage -provisioningSchemeName $ProvSchemeName -MasterImageVM $TargetSnapshot.fullpath -AdminAddress "ddc.citrix.com:80" -RunAsynchronously ##執行更新開始
Start-BrokerNaturalRebootCycle -AdminAddress "ddc.citrix.com:80" -InputObject @("TESTSCRIPTS") ##更新後直接重開
參考網址:
http://stealthpuppy.com/xendesktop-update-mcs-machine-catalog-powershell/
本文出自 “邁向Citrix大師之路” 博客,请务必保留此出处http://10802310.blog.51cto.com/10792310/1903739
如何使用XenDesktop的PowerShell來做Update Machines--限定Pool
标签:windows citrix update powershell
原文地址:http://10802310.blog.51cto.com/10792310/1903739