4646
4747. PARAMETER GalleryImageName
4848 Name of an Azure Local gallery (marketplace) image already downloaded to this cluster.
49- The script resolves its local VHDX path automatically and uses it as the test VM disk.
50- Takes precedence over -SourceVhdPath when both are provided.
51-
52- List available images:
53- az stack-hci-vm image list --resource-group <rg> --output table
49+ Resolves to the local VHDX automatically — recommended for realistic full-OS testing.
50+ List available images: az stack-hci-vm image list -g <rg> --output table
5451
5552. PARAMETER SourceVhdPath
56- Full path to an existing Windows Server VHDX to use as the test VM disk.
57- Use this if -GalleryImageName resolution fails, or to specify an exact file.
58- If neither -GalleryImageName nor -SourceVhdPath is set, an empty VHD is created.
53+ Explicit local path to a VHDX/VHD to copy into the test VM folder.
54+ Use when -GalleryImageName resolution fails or you have a custom template.
55+
56+ . PARAMETER IsoPath
57+ Path to a Windows Server ISO on the cluster node. The script converts it to a
58+ bootable VHDX using Convert-WindowsImage.ps1 (downloaded automatically from MSLab).
59+ Use with -Generation to produce Gen1 (MBR/BIOS) or Gen2 (GPT/UEFI) output.
60+
61+ . PARAMETER DownloadEvalIso
62+ Download the Windows Server 2022 Evaluation ISO from Microsoft automatically,
63+ then convert it to VHDX. Requires ~5 GB download + conversion time.
64+ Override the download URL with -EvalIsoUrl if the default link has changed.
65+
66+ . PARAMETER EvalIsoUrl
67+ Override the default Microsoft evaluation ISO download URL.
68+ Visit https://www.microsoft.com/en-us/evalcenter/download-windows-server-2022
69+ to get a current direct-download link if the default has expired.
70+
71+ . PARAMETER IsoEdition
72+ Windows Server edition to install when converting from ISO.
73+ Default: 'Windows Server 2022 Datacenter'
74+ Common values:
75+ 'Windows Server 2022 Standard'
76+ 'Windows Server 2022 Standard (Desktop Experience)'
77+ 'Windows Server 2022 Datacenter'
78+ 'Windows Server 2022 Datacenter (Desktop Experience)'
5979
6080. PARAMETER SkipSetup
6181 Skip the New-HydrationTestVM step. Use when the VM already exists.
6282
6383. EXAMPLE
64- # Azure resource layer test (empty VHD):
65- .\Invoke-HydrationTest.ps1 `
66- -ResourceGroup 'rg-azlocal-test ' `
67- -CustomLocation '/subscriptions/.../customlocations/cl -test' `
68- -StoragePathId '/subscriptions/.../storageContainers/UserStorage1' `
69- -StorageRootPath 'C:\ClusterStorage\Volume1' `
70- -SubnetId 'lnet-test-vlan10' `
71- -Location 'eastus '
84+ # Azure resource layer test only (empty VHD, no OS needed ):
85+ .\Invoke-HydrationTest.ps1 -ResourceGroup 'rg-test' -CustomLocation '...' `
86+ -StoragePathId '...' -StorageRootPath 'C:\ClusterStorage\csv-01 ' `
87+ -SubnetId 'lnet -test' -Location 'eastus'
88+
89+ . EXAMPLE
90+ # Use a marketplace image already on the cluster (recommended):
91+ .\Invoke-HydrationTest.ps1 ... -GalleryImageName 'windows-server-2022-datacenter '
7292
7393. EXAMPLE
74- # Full end-to-end test with real Windows Server VHD:
75- .\Invoke-HydrationTest.ps1 `
76- -ResourceGroup 'rg-azlocal-test' `
77- -CustomLocation '/subscriptions/.../customlocations/cl-test' `
78- -StoragePathId '/subscriptions/.../storageContainers/UserStorage1' `
79- -StorageRootPath 'C:\ClusterStorage\Volume1' `
80- -SubnetId 'lnet-test-vlan10' `
81- -Location 'eastus' `
82- -SourceVhdPath 'C:\ClusterStorage\csv-01\ISOs\WS2022_template.vhdx'
94+ # Use an ISO already on cluster storage:
95+ .\Invoke-HydrationTest.ps1 ... -IsoPath 'C:\ClusterStorage\csv-01\ISOs\WS2022.iso'
96+
97+ . EXAMPLE
98+ # Download eval ISO automatically and convert (Gen2):
99+ .\Invoke-HydrationTest.ps1 ... -DownloadEvalIso
100+
101+ . EXAMPLE
102+ # Download eval ISO and test Gen1 hydration path:
103+ .\Invoke-HydrationTest.ps1 ... -DownloadEvalIso -Generation 1
83104
84105. NOTES
85- Run on one of the Azure Local cluster nodes.
106+ Run on one of the Azure Local cluster nodes as Administrator .
86107 Azure CLI must be authenticated (az login).
108+ VHD source priority: GalleryImageName > IsoPath/DownloadEvalIso > SourceVhdPath > empty VHD.
87109#>
88110[CmdletBinding (SupportsShouldProcess )]
89111param (
@@ -121,6 +143,18 @@ param(
121143 [Parameter ()]
122144 [string ]$SourceVhdPath ,
123145
146+ [Parameter ()]
147+ [string ]$IsoPath ,
148+
149+ [Parameter ()]
150+ [switch ]$DownloadEvalIso ,
151+
152+ [Parameter ()]
153+ [string ]$EvalIsoUrl ,
154+
155+ [Parameter ()]
156+ [string ]$IsoEdition = ' Windows Server 2022 Datacenter' ,
157+
124158 [Parameter ()]
125159 [switch ]$SkipClusterCheck ,
126160
@@ -144,19 +178,63 @@ function Record-Pass([string]$msg) { $script:passed++; Write-TestPass $msg }
144178function Record-Fail ([string ]$msg ) { $script :failed ++ ; $script :failures.Add ($msg ); Write-TestFail $msg }
145179
146180# region ── Resolve VHD Source ─────────────────────────────────────────────────
181+ # Priority: GalleryImageName > IsoPath/DownloadEvalIso > SourceVhdPath > empty VHD
182+
183+ if (-not $SkipSetup ) {
184+
185+ if ($GalleryImageName ) {
186+ # ── Option 1: Marketplace / gallery image already on the cluster
187+ $resolvedPath = Get-GalleryImagePath `
188+ - ImageName $GalleryImageName `
189+ - ResourceGroup $ResourceGroup `
190+ - StorageRootPath $StorageRootPath
191+ if ($resolvedPath ) {
192+ $SourceVhdPath = $resolvedPath
193+ Write-Host " [VHD] Gallery image : $GalleryImageName " - ForegroundColor Cyan
194+ Write-Host " Local path : $SourceVhdPath " - ForegroundColor Cyan
195+ } else {
196+ Write-Host " [WARN] Gallery image '$GalleryImageName ' not resolved — check next option or use -SourceVhdPath." - ForegroundColor Yellow
197+ }
198+ }
199+
200+ if (-not $SourceVhdPath -and ($IsoPath -or $DownloadEvalIso )) {
201+ # ── Option 2: ISO → convert to VHDX
202+ $iso = $IsoPath
203+
204+ if ($DownloadEvalIso -and -not $iso ) {
205+ $isoFile = Join-Path $env: TEMP ' WS2022_eval.iso'
206+ $dlParams = @ { DestinationPath = $isoFile }
207+ if ($EvalIsoUrl ) { $dlParams [' DownloadUrl' ] = $EvalIsoUrl }
208+ $iso = Invoke-EvalIsoDownload @dlParams
209+ }
210+
211+ if ($iso ) {
212+ $genTag = " gen$Generation "
213+ $vhdxOut = Join-Path $env: TEMP " ws2022-test-${genTag} .vhdx"
214+ $cvParams = @ {
215+ IsoPath = $iso
216+ OutputPath = $vhdxOut
217+ Generation = $Generation
218+ Edition = $IsoEdition
219+ }
220+ $converted = Convert-IsoToVhdx @cvParams
221+ if ($converted ) {
222+ $SourceVhdPath = $converted
223+ Write-Host " [VHD] Converted ISO : Gen$Generation VHDX" - ForegroundColor Cyan
224+ Write-Host " Path : $SourceVhdPath " - ForegroundColor Cyan
225+ } else {
226+ Write-Host " [WARN] ISO conversion failed — falling back to empty VHD." - ForegroundColor Yellow
227+ }
228+ }
229+ }
147230
148- # Gallery image takes precedence; fall back to explicit SourceVhdPath; then empty VHD
149- if ($GalleryImageName -and -not $SkipSetup ) {
150- $resolvedPath = Get-GalleryImagePath `
151- - ImageName $GalleryImageName `
152- - ResourceGroup $ResourceGroup `
153- - StorageRootPath $StorageRootPath
154- if ($resolvedPath ) {
155- $SourceVhdPath = $resolvedPath
156- Write-Host " Using gallery image: $GalleryImageName " - ForegroundColor Cyan
157- Write-Host " Local path : $SourceVhdPath " - ForegroundColor Cyan
231+ if ($SourceVhdPath ) {
232+ # ── Option 3: Explicit path already set (from above or passed directly)
233+ Write-Host " [VHD] Source VHDX : $SourceVhdPath " - ForegroundColor Cyan
158234 } else {
159- Write-Host " [WARN] Could not resolve gallery image '$GalleryImageName ' — falling back to empty VHD." - ForegroundColor Yellow
235+ # ── Option 4: Empty VHD — Azure resource layer testing only
236+ Write-Host " [VHD] Mode: empty VHD (no OS) — Azure resource registration only." - ForegroundColor Yellow
237+ Write-Host " Supply -GalleryImageName, -IsoPath, -DownloadEvalIso, or -SourceVhdPath for full OS testing." - ForegroundColor Yellow
160238 }
161239}
162240
0 commit comments