@@ -18,8 +18,9 @@ $VMSize = 'Standard_F32as_v6'
18
18
$ProtoVMName = ' PROTOTYPE'
19
19
$ImagePublisher = ' MicrosoftWindowsServer'
20
20
$ImageOffer = ' WindowsServer'
21
- $ImageSku = ' 2025-datacenter-g2 '
21
+ $ImageSku = ' 2025-datacenter-azure-edition '
22
22
23
+ $LogFile = ' 1es-hosted-pool.log'
23
24
$ProgressActivity = ' Preparing STL CI pool'
24
25
$TotalProgress = 26
25
26
$CurrentProgress = 1
@@ -78,13 +79,13 @@ $Env:SuppressAzurePowerShellBreakingChangeWarnings = 'true'
78
79
79
80
Update-AzConfig `
80
81
- DisplayBreakingChangeWarning $false `
81
- - Scope ' Process' | Out-Null
82
+ - Scope ' Process' >> $LogFile
82
83
83
84
# ###################################################################################################
84
85
Display- ProgressBar - Status ' Setting the subscription context'
85
86
86
87
Set-AzContext `
87
- - SubscriptionName ' CPP_STL_GitHub' | Out-Null
88
+ - SubscriptionName ' CPP_STL_GitHub' >> $LogFile
88
89
89
90
# ###################################################################################################
90
91
Display- ProgressBar - Status ' Creating resource group'
@@ -93,7 +94,7 @@ $ResourceGroupName = 'StlBuild-' + $CurrentDate.ToString('yyyy-MM-ddTHHmm')
93
94
94
95
New-AzResourceGroup `
95
96
- Name $ResourceGroupName `
96
- - Location $Location | Out-Null
97
+ - Location $Location >> $LogFile
97
98
98
99
# ###################################################################################################
99
100
Display- ProgressBar - Status ' Creating credentials'
@@ -169,7 +170,7 @@ $VM = Set-AzVMBootDiagnostic `
169
170
New-AzVm `
170
171
- ResourceGroupName $ResourceGroupName `
171
172
- Location $Location `
172
- - VM $VM | Out-Null
173
+ - VM $VM >> $LogFile
173
174
174
175
$VM = Get-AzVM `
175
176
- ResourceGroupName $ResourceGroupName `
@@ -192,7 +193,7 @@ if ($ProvisionImageResult.value.Message -cnotmatch 'PROVISION_IMAGE_SUCCEEDED')
192
193
193
194
Stop-AzVM `
194
195
- Id $VM.ID `
195
- - Force | Out-Null
196
+ - Force >> $LogFile
196
197
197
198
Write-Error " VM stopped. Remember to delete unusable resource group: $ResourceGroupName "
198
199
}
@@ -201,7 +202,7 @@ if ($ProvisionImageResult.value.Message -cnotmatch 'PROVISION_IMAGE_SUCCEEDED')
201
202
Display- ProgressBar - Status ' Restarting VM'
202
203
203
204
Restart-AzVM `
204
- - Id $VM.ID | Out-Null
205
+ - Id $VM.ID >> $LogFile
205
206
206
207
# ###################################################################################################
207
208
Display- ProgressBar - Status ' Sleeping after restart'
@@ -216,7 +217,7 @@ Display-ProgressBar -Status 'Running sysprep in VM'
216
217
Invoke-AzVMRunCommand `
217
218
- ResourceId $VM.ID `
218
219
- CommandId ' RunPowerShellScript' `
219
- - ScriptString ' C:\Windows\system32\sysprep\sysprep.exe /oobe /generalize /mode:vm /shutdown' | Out-Null
220
+ - ScriptString ' C:\Windows\system32\sysprep\sysprep.exe /oobe /generalize /mode:vm /shutdown' >> $LogFile
220
221
221
222
# ###################################################################################################
222
223
Display- ProgressBar - Status ' Waiting for VM to shut down'
@@ -230,14 +231,14 @@ Display-ProgressBar -Status 'Stopping VM'
230
231
231
232
Stop-AzVM `
232
233
- Id $VM.ID `
233
- - Force | Out-Null
234
+ - Force >> $LogFile
234
235
235
236
# ###################################################################################################
236
237
Display- ProgressBar - Status ' Generalizing VM'
237
238
238
239
Set-AzVM `
239
240
- Id $VM.ID `
240
- - Generalized | Out-Null
241
+ - Generalized >> $LogFile
241
242
242
243
# ###################################################################################################
243
244
Display- ProgressBar - Status ' Creating gallery'
@@ -256,7 +257,7 @@ $ServicePrincipalObjectId = (Get-AzADServicePrincipal -DisplayName '1ES Resource
256
257
New-AzRoleAssignment `
257
258
- ObjectId $ServicePrincipalObjectId `
258
259
- RoleDefinitionName ' Reader' `
259
- - Scope $Gallery.Id | Out-Null
260
+ - Scope $Gallery.Id >> $LogFile
260
261
261
262
# ###################################################################################################
262
263
Display- ProgressBar - Status ' Creating image definition'
@@ -276,7 +277,7 @@ New-AzGalleryImageDefinition `
276
277
- Offer $ImageOffer `
277
278
- Sku $ImageSku `
278
279
- Feature $ImageDefinitionFeatures `
279
- - HyperVGeneration ' V2' | Out-Null
280
+ - HyperVGeneration ' V2' >> $LogFile
280
281
281
282
# ###################################################################################################
282
283
Display- ProgressBar - Status ' Creating image version'
@@ -294,7 +295,7 @@ $ImageVersion = New-AzGalleryImageVersion `
294
295
Display- ProgressBar - Status ' Registering CloudTest resource provider'
295
296
296
297
Register-AzResourceProvider `
297
- - ProviderNamespace ' Microsoft.CloudTest' | Out-Null
298
+ - ProviderNamespace ' Microsoft.CloudTest' >> $LogFile
298
299
299
300
# ###################################################################################################
300
301
Display- ProgressBar - Status ' Creating 1ES image'
@@ -306,7 +307,7 @@ New-AzResource `
306
307
- ResourceType ' Microsoft.CloudTest/Images' `
307
308
- ResourceName $ImageName `
308
309
- Properties @ { ' imageType' = ' SharedImageGallery' ; ' resourceId' = $ImageVersion.Id ; } `
309
- - Force | Out-Null
310
+ - Force >> $LogFile
310
311
311
312
# ###################################################################################################
312
313
Display- ProgressBar - Status ' Creating 1ES Hosted Pool'
@@ -328,46 +329,46 @@ New-AzResource `
328
329
- ResourceType ' Microsoft.CloudTest/hostedpools' `
329
330
- ResourceName $PoolName `
330
331
- Properties $PoolProperties `
331
- - Force | Out-Null
332
+ - Force >> $LogFile
332
333
333
334
# ###################################################################################################
334
335
Display- ProgressBar - Status ' Deleting unused VM'
335
336
336
337
Remove-AzVM `
337
338
- Id $VM.ID `
338
- - Force | Out-Null
339
+ - Force >> $LogFile
339
340
340
341
# ###################################################################################################
341
342
Display- ProgressBar - Status ' Deleting unused disk'
342
343
343
344
Remove-AzDisk `
344
345
- ResourceGroupName $ResourceGroupName `
345
346
- DiskName $PrototypeOSDiskName `
346
- - Force | Out-Null
347
+ - Force >> $LogFile
347
348
348
349
# ###################################################################################################
349
350
Display- ProgressBar - Status ' Deleting unused network interface'
350
351
351
352
Remove-AzNetworkInterface `
352
353
- ResourceGroupName $ResourceGroupName `
353
354
- Name $NicName `
354
- - Force | Out-Null
355
+ - Force >> $LogFile
355
356
356
357
# ###################################################################################################
357
358
Display- ProgressBar - Status ' Deleting unused virtual network'
358
359
359
360
Remove-AzVirtualNetwork `
360
361
- ResourceGroupName $ResourceGroupName `
361
362
- Name $VirtualNetworkName `
362
- - Force | Out-Null
363
+ - Force >> $LogFile
363
364
364
365
# ###################################################################################################
365
366
Display- ProgressBar - Status ' Deleting unused network security group'
366
367
367
368
Remove-AzNetworkSecurityGroup `
368
369
- ResourceGroupName $ResourceGroupName `
369
370
- Name $NetworkSecurityGroupName `
370
- - Force | Out-Null
371
+ - Force >> $LogFile
371
372
372
373
# ###################################################################################################
373
374
Write-Progress - Activity $ProgressActivity - Completed
0 commit comments