**功能狀態:**有限可用性 (LA)
概觀
若要搭配 Horizon Cloud 使用 Amazon Core 受管理執行個體 (CMI),您必須先準備 Windows 映像,方法是將支援的 Windows ISO 匯入 AWS、使用 EC2 Image Builder 建立基礎 AMI,然後使用 EC2 Image Builder 元件、映像建置定義和管線,搭配 Horizon Agent Installer (HAI) 自訂 AMI。
本主題說明一般準備步驟,以及 CMI 專用的映像自訂工作流程。
**附註:**此方法與 Amazon WorkSpaces Core 方法 (方法 1:AWS EC2 自訂執行個體匯入、方法 2 和方法 3) 不同。請勿將此處所述的步驟與上述方法混用,因為兩者的工作流程不同。
一般準備步驟
建立 CMI 的 Windows 映像之前,請依序完成下列準備工作。這些步驟可確保您的環境、權限和來源映像已準備妥當,可供 AWS EC2 Image Builder 使用。
如需各步驟的詳細程序,請參閱在 AWS 上建立 Horizon Windows 映像的通用準備步驟。
-
取得 Horizon on AWS 支援的 Windows ISO - 從 Microsoft 官方網站下載支援的 Windows ISO (例如 Windows 11 Enterprise 25H2 或 24H2)。
-
將 Windows ISO 上傳至 Amazon S3 值區 - 將 ISO 檔案上傳至 AWS Image Builder 可存取的 Amazon S3 值區。ISO 副檔名必須使用大寫 (例如
Windows11.ISO)。 -
為 EC2 Image Builder 建立 IAM 角色 - 建立具有下列權限原則的 IAM 角色:
AmazonSSMManagedInstanceCoreEC2InstanceProfileForImageBuilderEC2InstanceProfileForImageBuilderECRContainerBuilds
-
建立 EC2 Image Builder 基礎結構組態 - 定義映像建置和測試作業期間使用的運算、網路和通知設定,包括執行個體類型、VPC、子網路、安全群組和 SNS 主題。
匯入 Windows ISO 並建立基礎 AMI
完成一般準備步驟後,請使用 EC2 Image Builder 將 Windows ISO 匯入 AWS,以建立基礎 Amazon 機器映像 (AMI)。之後會使用產生的 AMI 作為映像建置定義的父系映像。
程序
- 從 AWS 管理主控台中,前往 EC2 Image Builder。
- 在導覽窗格中,選擇映像。
- 選取匯入映像。
- 在一般區段中,提供下列資訊:
- 名稱 - 輸入映像的唯一名稱。
- 版本 - 使用
major.minor.patch格式指定版本號碼。
- 在匯入類型中,選取 ISO 匯入。
- 在 ISO 匯入組態區段中,提供下列詳細資料:
- S3 URI - 指定儲存 Windows ISO 檔案的 Amazon S3 位置。
- IAM 角色 - 選取您在一般準備步驟中建立的 IAM 角色。
- 在 ISO 基礎結構組態中,選取您在一般準備步驟中建立的基礎結構組態。
- 選擇匯入映像,以開始 ISO 匯入程序。
- 在 EC2 Image Builder 中監控匯入狀態,直到映像建立成功完成為止。
驗證基礎 AMI
完成 ISO 匯入後,請先確認基礎 AMI 可供使用,再繼續執行後續步驟:
- 在 EC2 Image Builder 中,導覽至映像。
- 找到從 ISO 匯入所建立的映像。
- 確認上次成功狀態顯示為可用。
使用 Horizon Agent 安裝程式自訂 Windows AMI
建立並驗證基礎 AMI 後,請使用 EC2 Image Builder 元件、映像建置定義和映像管線,搭配 Horizon Agent 安裝程式自訂 AMI。此方法可自動執行自訂作業,而無需手動建立 RDP 工作階段。
步驟 1:建立自訂 EC2 Image Builder 元件
在 EC2 Image Builder 中建立自訂元件,以自動安裝 Horizon Agent 並設定 OOBE 設定。每個元件均定義為 YAML 文件。
若要建立自訂元件:
- 在 EC2 Image Builder 中,導覽至元件,然後按一下建立元件。
- 在映像作業系統中,選取 Windows。作業系統版本由 ISO 決定,因此不需要另外指定。
- 將 KMS 伺服器保留為預設值。
- 使用 YAML 文件格式定義元件內容。
- 按一下建立元件。
建立下列四個元件。在下一個步驟中,將這些元件新增至映像建置定義的順序非常重要。
元件 1:安裝前 RunOnce 備份
將所有 HKLM RunOnce 金鑰 (64 位元和 Wow6432Node) 備份至 C:\Windows\Temp,然後移除所有 RunOnce 值,避免 Horizon Agent 安裝程式偵測到待重新開機狀態 (結束代碼 0x643)。在 Horizon Agent 安裝元件之前立即執行此元件。
# DISCLAIMER:
# This script/YAML file is provided as a sample for reference purposes only.
# It is not intended for production use without proper review, testing, and validation.
# Users are responsible for evaluating and modifying the content to meet their
# security, compliance, and operational requirements.
# No warranties or guarantees are provided.
name: HorizonAgentPreInstallRunOnceBackup
description: Backs up all HKLM RunOnce keys/values (64-bit and Wow6432Node) to C:\Windows\Temp, then removes all RunOnce values so the Horizon Agent installer does not detect a pending reboot (exit 0x643). Run immediately before the Horizon Agent install component.
schemaVersion: 1.0
phases:
- name: build
steps:
- name: ShowRunOnceValues
action: ExecutePowerShell
onFailure: Continue
inputs:
commands:
- |
foreach ($p in 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce') {
Write-Host "== $p =="
Get-ItemProperty -Path $p -ErrorAction SilentlyContinue | Format-List
}
- name: BackupAllRunOnceKeys
action: ExecutePowerShell
onFailure: Abort
inputs:
commands:
- |
$targets = @(
@{ Reg = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce'; Ps = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce'; File = 'C:\Windows\Temp\RunOnce_HKLM_backup' },
@{ Reg = 'HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce'; Ps = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce'; File = 'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup' }
)
foreach ($t in $targets) {
if (-not (Test-Path $t.Ps)) {
Write-Host "Key not present, skipping: $($t.Reg)"
continue
}
$regFile = "$($t.File).reg"
& reg.exe export $t.Reg $regFile /y
if ($LASTEXITCODE -ne 0) { Write-Error "reg export failed ($LASTEXITCODE) for $($t.Reg)"; exit 1 }
if (-not (Test-Path $regFile)) { Write-Error "Backup file not found: $regFile"; exit 1 }
Write-Host "Backup written to $regFile"
$jsonFile = "$($t.File).json"
$items = @(Get-Item -Path $t.Ps) + @(Get-ChildItem -Path $t.Ps -Recurse -ErrorAction SilentlyContinue)
$rows = foreach ($k in $items) {
foreach ($n in $k.GetValueNames()) {
[pscustomobject]@{
Key = $k.Name
Name = $n
Type = $k.GetValueKind($n).ToString()
Value = $k.GetValue($n, $null, 'DoNotExpandEnvironmentNames')
}
}
}
@($rows) | ConvertTo-Json -Depth 4 | Set-Content -Path $jsonFile -Encoding UTF8
Write-Host "Value inventory written to $jsonFile ($(@($rows).Count) values)"
}
- name: RemoveAllRunOnceValues
action: ExecutePowerShell
onFailure: Abort
inputs:
commands:
- |
# SAFETY: $true = log only (dry run). Set to $false to actually delete.
$DryRun = $false
$roots = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce'
)
foreach ($root in $roots) {
if (-not (Test-Path $root)) { Write-Host "Key not present, skipping: $root"; continue }
# Root key plus any subkeys (e.g. RunOnce\Setup). Subkeys themselves are kept; only values are removed.
$keys = @(Get-Item -Path $root) + @(Get-ChildItem -Path $root -Recurse -ErrorAction SilentlyContinue)
foreach ($k in $keys) {
foreach ($n in $k.GetValueNames()) {
if ([string]::IsNullOrEmpty($n)) { continue } # skip (Default)
if ($DryRun) {
Write-Host "[DRY RUN] Would remove '$n' from $($k.Name)"
} else {
Remove-ItemProperty -LiteralPath $k.PSPath -Name $n -ErrorAction Stop
Write-Host "Removed '$n' from $($k.Name)"
}
}
}
}
exit 0
元件 2:安裝 Omnissa Horizon Agent
下載並以無訊息方式安裝 Omnissa Horizon Agents Installer。此安裝程式具備復原能力 -- 如果遇到 1603 錯誤,系統會重新開機並重試 (最多 2 次)。
# DISCLAIMER:
# This script/YAML file is provided as a sample for reference purposes only.
# It is not intended for production use without proper review, testing, and validation.
# Users are responsible for evaluating and modifying the content to meet their
# security, compliance, and operational requirements.
# No warranties or guarantees are provided.
name: InstallOmnissaHorizonAgents
description: Downloads and silently installs Omnissa Horizon Agents Installer 26.3.0 (resilient, reboot-and-retry on 1603)
schemaVersion: 1.0
phases:
- name: build
steps:
- name: CheckPendingReboot
action: ExecutePowerShell
onFailure: Continue
inputs:
commands:
- |
$pending = @()
if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') { $pending += 'CBS' }
if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') { $pending += 'WindowsUpdate' }
$pfro = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -ErrorAction SilentlyContinue).PendingFileRenameOperations
if ($pfro) { $pending += 'PendingFileRename' }
if ($pending.Count -gt 0) {
Write-Warning "Pending reboot detected ($($pending -join ', ')). Skipping reboot and continuing installation."
} else {
Write-Host "No pending reboot detected."
}
exit 0
- name: DownloadHorizonAgents
action: WebDownload
maxAttempts: 3
timeoutSeconds: 1800
onFailure: Abort
inputs:
- source: https://softwareupdate.omnissa.com/horizoncloud-v2-agents/packages/HAI-Agent/26.3.0/40775428445/Omnissa-Horizon-Agents-Installer-26.3.0-40775428445-x64.exe
destination: C:\Windows\Temp\Omnissa-Horizon-Agents-Installer.exe
overwrite: true
- name: InstallHorizonAgents
action: ExecutePowerShell
maxAttempts: 2
timeoutSeconds: 3600
onFailure: Abort
inputs:
commands:
- |
$ErrorActionPreference = 'Stop'
$installer = 'C:\Windows\Temp\Omnissa-Horizon-Agents-Installer.exe'
$sourceUrl = 'https://softwareupdate.omnissa.com/horizoncloud-v2-agents/packages/HAI-Agent/26.3.0/40775428445/Omnissa-Horizon-Agents-Installer-26.3.0-40775428445-x64.exe'
$log = 'C:\Windows\Temp\HorizonAgents_install_wrapper.log'
$retryFile = 'C:\Windows\Temp\HorizonAgents_1603_retry.txt' # survives reboot
$maxRebootRetries = 2
function Log($m) { "$(Get-Date -Format s) $m" | Out-File $log -Append; Write-Host $m }
$retryCount = 0
if (Test-Path $retryFile) { $retryCount = [int](Get-Content $retryFile -Raw) }
if ($retryCount -gt 0) { Log "Resuming after reboot (1603 retry #$retryCount)." }
# Idempotency check - skipped during 1603 retries (failed installs can leave partial uninstall entries)
if ($retryCount -eq 0) {
$keys = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
$existing = Get-ItemProperty $keys -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName -like '*Omnissa Horizon*' }
if ($existing) { Log "Already installed: $($existing.DisplayName -join ', '). Skipping."; exit 0 }
}
# Re-download if installer is missing after reboot
if (-not (Test-Path $installer)) {
Log "Installer missing. Re-downloading..."
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $sourceUrl -OutFile $installer -UseBasicParsing
if (-not (Test-Path $installer)) { Log "ERROR: Re-download failed."; exit 1 }
}
Log "Starting install..."
$p = Start-Process -FilePath $installer -ArgumentList '/silent','/norestart' -Wait -PassThru
$code = $p.ExitCode
Log "Installer exit code: $code"
switch ($code) {
0 { Remove-Item $retryFile -Force -ErrorAction SilentlyContinue; Log "Install succeeded."; exit 0 }
3010 { Remove-Item $retryFile -Force -ErrorAction SilentlyContinue; Log "Install succeeded; reboot handled by next step."; exit 0 }
1641 { Remove-Item $retryFile -Force -ErrorAction SilentlyContinue; Log "Install succeeded; installer initiated reboot."; exit 0 }
1603 {
if ($retryCount -lt $maxRebootRetries) {
$retryCount++
Set-Content -Path $retryFile -Value $retryCount
Log "1603 received. Rebooting and retrying ($retryCount of $maxRebootRetries)..."
exit 3010 # AWSTOE: reboot the instance, then re-run this step
}
Log "ERROR: 1603 persisted after $maxRebootRetries reboot/retry cycles."
Remove-Item $retryFile -Force -ErrorAction SilentlyContinue
exit 1603
}
default { Log "ERROR: Install failed with exit code $code"; exit $code }
}
- name: RebootAfterInstall
action: Reboot
onFailure: Continue
inputs:
delaySeconds: 30
- name: CleanupInstaller
action: ExecutePowerShell
onFailure: Continue
inputs:
commands:
- |
Remove-Item 'C:\Windows\Temp\Omnissa-Horizon-Agents-Installer.exe' -Force -ErrorAction SilentlyContinue
Remove-Item 'C:\Windows\Temp\HorizonAgents_1603_retry.txt' -Force -ErrorAction SilentlyContinue
exit 0
- name: validate
steps:
- name: VerifyInstallation
action: ExecutePowerShell
onFailure: Continue
inputs:
commands:
- |
$keys = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
$found = Get-ItemProperty $keys -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName -like '*Omnissa Horizon*' }
if ($found) {
$found | ForEach-Object { Write-Host "Installed: $($_.DisplayName) $($_.DisplayVersion)" }
} else {
Write-Warning "Omnissa Horizon Agents not found"
}
exit 0
元件 3:安裝後 RunOnce 還原
從安裝前備份元件建立的 C:\Windows\Temp 備份中還原所有 HKLM RunOnce 金鑰,並對照值詳細目錄進行驗證,然後重新開機。
# DISCLAIMER:
# This script/YAML file is provided as a sample for reference purposes only.
# It is not intended for production use without proper review, testing, and validation.
# Users are responsible for evaluating and modifying the content to meet their
# security, compliance, and operational requirements.
# No warranties or guarantees are provided.
name: HorizonAgentPostInstallRunOnceRestore
description: Restores all HKLM RunOnce keys/values (64-bit and Wow6432Node) from the C:\Windows\Temp backups created by HorizonAgentPreInstallRunOnceBackup after the Horizon Agent install, verifies them against the value inventory, then reboots.
schemaVersion: 1.0
phases:
- name: build
steps:
- name: ImportRunOnceBackups
action: ExecutePowerShell
onFailure: Abort
inputs:
commands:
- |
$backups = @(
'C:\Windows\Temp\RunOnce_HKLM_backup.reg',
'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup.reg'
)
$imported = 0
foreach ($b in $backups) {
if (-not (Test-Path $b)) {
# Backup step skips keys that did not exist, so a missing file is not an error
Write-Host "Backup not found, skipping: $b"
continue
}
& reg.exe import $b
if ($LASTEXITCODE -ne 0) { Write-Error "reg import failed ($LASTEXITCODE) for $b"; exit 1 }
Write-Host "Imported $b"
$imported++
}
if ($imported -eq 0) { Write-Error "No RunOnce backup files found in C:\Windows\Temp"; exit 1 }
- name: VerifyRestoredRunOnceValues
action: ExecutePowerShell
onFailure: Continue
inputs:
commands:
- |
$inventories = @(
@{ Json = 'C:\Windows\Temp\RunOnce_HKLM_backup.json' },
@{ Json = 'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup.json' }
)
$missing = 0; $checked = 0
foreach ($i in $inventories) {
if (-not (Test-Path $i.Json)) { Write-Host "Inventory not found, skipping: $($i.Json)"; continue }
$rows = @(Get-Content -Raw -Path $i.Json | ConvertFrom-Json)
foreach ($r in $rows) {
if ($null -eq $r -or [string]::IsNullOrEmpty($r.Name)) { continue }
$checked++
$psKey = 'Registry::' + $r.Key
$cur = Get-ItemProperty -LiteralPath $psKey -Name $r.Name -ErrorAction SilentlyContinue
if ($cur) { Write-Host "Restored: $($r.Key)\$($r.Name)" }
else { Write-Warning "NOT restored: $($r.Key)\$($r.Name)"; $missing++ }
}
}
Write-Host "Checked $checked values; $missing missing"
- name: RebootAfterRestore
action: Reboot
onFailure: Abort
inputs:
delaySeconds: 60
- name: CleanupBackups
action: ExecutePowerShell
onFailure: Continue
inputs:
commands:
- |
Remove-Item -Path 'C:\Windows\Temp\RunOnce_HKLM_backup.reg',
'C:\Windows\Temp\RunOnce_HKLM_backup.json',
'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup.reg',
'C:\Windows\Temp\RunOnce_HKLM_Wow6432Node_backup.json' -Force -ErrorAction SilentlyContinue
Write-Host "Backup files removed"
元件 4:設定 OOBE 自動安裝
將 OOBE、UserAccounts、AutoLogon,以及地區設定/鍵盤設定新增至 EC2Launch v2 Sysprep 自動安裝檔案,以避免在設定期間手動輸入作業系統資訊。
# DISCLAIMER:
# This script/YAML file is provided as a sample for reference purposes only.
# It is not intended for production use without proper review, testing, and validation.
# Users are responsible for evaluating and modifying the content to meet their
# security, compliance, and operational requirements.
# No warranties or guarantees are provided.
name: ConfigureOOBEUnattend
description: Adds OOBE, UserAccounts, AutoLogon and locale/keyboard settings to the EC2Launch v2 Sysprep unattend file
schemaVersion: 1.0
phases:
- name: build
steps:
- name: UpdateEC2LaunchUnattend
action: ExecutePowerShell
onFailure: Abort
inputs:
commands:
- |
$path = 'C:\ProgramData\Amazon\EC2Launch\sysprep\unattend.xml'
if (-not (Test-Path $path)) { Write-Host "ERROR: $path not found"; exit 1 }
Copy-Item $path "$path.bak" -Force
[xml]$xml = Get-Content $path
$uri = 'urn:schemas-microsoft-com:unattend'
$ns = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
$ns.AddNamespace('u', $uri)
$shell = $xml.SelectSingleNode("//u:settings[@pass='oobeSystem']/u:component[@name='Microsoft-Windows-Shell-Setup']", $ns)
if (-not $shell) { Write-Host "ERROR: oobeSystem Shell-Setup component not found"; exit 1 }
# Create/set a nested element path under a parent, e.g. Set-Node $shell @('OOBE','HideEULAPage') 'true'
function Set-Node($parent, [string[]]$names, [string]$value) {
$cur = $parent
foreach ($name in $names) {
$child = $cur.SelectSingleNode("u:$name", $ns)
if (-not $child) { $child = $xml.CreateElement($name, $uri); [void]$cur.AppendChild($child) }
$cur = $child
}
$cur.InnerText = $value
}
# Random throwaway password generated at build time (never logged, never stored in source).
# EC2Launch resets the Administrator password at instance launch.
$bytes = New-Object byte[] 18
[Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
$pw = [Convert]::ToBase64String($bytes) + 'aA1!'
# UserAccounts
Set-Node $shell @('UserAccounts','AdministratorPassword','Value') $pw
Set-Node $shell @('UserAccounts','AdministratorPassword','PlainText') 'true'
# AutoLogon
Set-Node $shell @('AutoLogon','Username') 'Administrator'
Set-Node $shell @('AutoLogon','Enabled') 'true'
Set-Node $shell @('AutoLogon','LogonCount') '1'
Set-Node $shell @('AutoLogon','Password','Value') $pw
Set-Node $shell @('AutoLogon','Password','PlainText') 'true'
# OOBE
$oobe = [ordered]@{
HideEULAPage = 'true'
ProtectYourPC = '3'
HideWirelessSetupInOOBE = 'true'
HideOnlineAccountScreens = 'true'
NetworkLocation = 'Work'
}
foreach ($k in $oobe.Keys) { Set-Node $shell @('OOBE', $k) $oobe[$k] }
# Locale / keyboard (pre-answers the Country, Keyboard layout and Second keyboard OOBE pages)
$settingsNode = $shell.ParentNode
$intl = $settingsNode.SelectSingleNode("u:component[@name='Microsoft-Windows-International-Core']", $ns)
if (-not $intl) {
$intl = $xml.CreateElement('component', $uri)
$attrs = [ordered]@{ name='Microsoft-Windows-International-Core'; processorArchitecture='amd64'; publicKeyToken='31bf3856ad364e35'; language='neutral'; versionScope='nonSxS' }
foreach ($a in $attrs.Keys) { $intl.SetAttribute($a, $attrs[$a]) }
[void]$settingsNode.AppendChild($intl)
}
$locale = [ordered]@{
InputLocale = '0409:00000409' # single US keyboard; no secondary layout page
SystemLocale = 'en-US'
UILanguage = 'en-US'
UserLocale = 'en-US' # sets country/region format
}
foreach ($k in $locale.Keys) { Set-Node $intl @($k) $locale[$k] }
$xml.Save($path)
Write-Host "Updated $path"
- name: validate
steps:
- name: VerifyUnattendSettings
action: ExecutePowerShell
onFailure: Abort
inputs:
commands:
- |
$path = 'C:\ProgramData\Amazon\EC2Launch\sysprep\unattend.xml'
[xml]$xml = Get-Content $path
$ns = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
$ns.AddNamespace('u', 'urn:schemas-microsoft-com:unattend')
$base = "//u:settings[@pass='oobeSystem']/u:component[@name='Microsoft-Windows-Shell-Setup']"
$ic = "//u:settings[@pass='oobeSystem']/u:component[@name='Microsoft-Windows-International-Core']"
$checks = [ordered]@{
"$base/u:OOBE/u:HideEULAPage" = 'true'
"$base/u:OOBE/u:ProtectYourPC" = '3'
"$base/u:OOBE/u:HideWirelessSetupInOOBE" = 'true'
"$base/u:OOBE/u:HideOnlineAccountScreens" = 'true'
"$base/u:OOBE/u:NetworkLocation" = 'Work'
"$base/u:AutoLogon/u:Username" = 'Administrator'
"$base/u:AutoLogon/u:Enabled" = 'true'
"$base/u:AutoLogon/u:LogonCount" = '1'
"$ic/u:InputLocale" = '0409:00000409'
"$ic/u:SystemLocale" = 'en-US'
"$ic/u:UILanguage" = 'en-US'
"$ic/u:UserLocale" = 'en-US'
}
$failed = $false
foreach ($xp in $checks.Keys) {
$n = $xml.SelectSingleNode($xp, $ns)
if (-not $n -or $n.InnerText -ne $checks[$xp]) { Write-Host "ERROR: missing/incorrect $xp"; $failed = $true }
}
# Presence-only checks for password nodes (values are never printed)
foreach ($xp in @("$base/u:UserAccounts/u:AdministratorPassword/u:Value", "$base/u:AutoLogon/u:Password/u:Value")) {
$n = $xml.SelectSingleNode($xp, $ns)
if (-not $n -or [string]::IsNullOrEmpty($n.InnerText)) { Write-Host "ERROR: missing $xp"; $failed = $true }
}
if ($failed) { exit 1 }
Write-Host "OOBE, UserAccounts, AutoLogon and locale settings present in $path"
步驟 2:建立映像建置定義
建立元件後,請建立映像建置定義,將從 ISO 匯入建立的基礎 AMI 與自訂元件依特定順序組合。
若要建立映像建置定義:
- 在 EC2 Image Builder 中,導覽至映像建置定義,然後按一下建立建置定義。
- 選取從 ISO 匯入所建立的映像,作為基礎/父系映像。
- 選取基礎結構組態。
- 依下列確切順序新增建置元件:
| 順序 | 元件 | 用途 |
|---|---|---|
| 1 | HorizonAgentPreInstallRunOnceBackup | 備份 RunOnce 金鑰,避免 HAI 安裝程式偵測到待重新開機狀態 |
| 2 | InstallOmnissaHorizonAgents | 安裝 Omnissa Horizon Agent |
| 3 | HorizonAgentPostInstallRunOnceRestore | 還原已備份的 RunOnce 金鑰 |
| 4 | ConfigureOOBEUnattend | 設定 OOBE、自動登入及地區設定 |
- 選取散佈設定。
- 按一下建立建置定義。
**重要:**元件順序非常重要。必須先執行安裝前 RunOnce 備份,再執行 HAI 安裝程式,以避免安裝程式偵測到待重新開機狀態 (結束代碼 0x643)。必須在 HAI 安裝程式之後執行安裝後 RunOnce 還原,以還原已備份的金鑰。
步驟 3:建立映像管線
建立映像建置定義後,請建立映像管線,將元件、建置定義和基礎結構組態組合起來,以產生最終的 AMI。
若要建立映像管線:
- 在 EC2 Image Builder 中,導覽至管線,然後按一下建立管線。
- 在一般區段中,輸入管線名稱。
- 選擇執行類型:
- 手動 - 視需要執行管線。
- 已排程 - 依排程執行管線。
- 選取映像建置定義及其版本。
- 確認元件依正確順序列出 (PreInstall RunOnce → HAI → PostInstall RunOnce → OOBE)。
- 將工作流程保留為預設值。
- 選取在一般準備步驟中建立的基礎結構組態。
- 設定散佈設定 (使用現有設定或建立新設定)。
- 按一下建立管線。
管線工作流程階段:
- 建置 - 啟動建置執行個體、等待 SSM 代理程式就緒、執行建置元件、從自訂的執行個體建立 AMI,然後終止建置執行個體。
- 測試 - 從新的 AMI 啟動全新的執行個體、執行測試元件並收集結果。如果任何測試失敗,映像會標示為失敗。
- 散佈 (選用) - 將 AMI 複製到目標區域,並套用共用設定。
若要執行管線:
- 選取管線,然後選擇動作 > 執行管線。
- 工作流程引擎會依序協調執行:建置 → 測試 → 散佈。
- 若要檢視輸出映像,請選取管線 > 輸出映像 > 選擇版本。在輸出資源下方會顯示 AMI 識別碼。
如需建立 EC2 Image Builder 管線的其他指引,請參閱 AWS Builder Center 文章:為 Amazon WorkSpaces 建置 EC2 Image Builder 管線 -- 逐步指南。
步驟 4:驗證映像並在 Horizon Cloud IMS 中登錄
管線完成後,請驗證映像,並在 Horizon Cloud 中登錄,以建立 CMI 型映像。
- 在 EC2 Image Builder 中,導覽至該管線,並確認映像狀態顯示為可用。
- (選用) 從建立的 AMI 啟動測試執行個體,以驗證組態:
- 選取 AMI,然後按一下從 AMI 啟動執行個體。
- 提供金鑰配對詳細資料。
- 登入執行個體,並確認 Horizon Agent 及所有組態皆正確。
- 驗證完成後,請在 Horizon Cloud 映像管理服務 (IMS) 中登錄 AMI,以建立 CMI 型映像。如需詳細資料,請參閱 Horizon Cloud Console 映像匯入工作流程。
**附註:**Horizon Cloud 中的 CMI 映像登錄另有說明文件。如需登錄程序,請參閱使用 AMI 登錄 AWS CMI 映像。
相關參照
此頁面對您有幫助嗎?