Skip to content

Commit 008cb68

Browse files
authored
Merge pull request #116116 from danielsollondon/patch-27
Update to sysprep command
2 parents f31598b + afc374a commit 008cb68

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

articles/virtual-machines/linux/image-builder-json.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,24 @@ If Azure Image Builder creates a Windows custom image successfully, and you crea
422422

423423
#### Default Sysprep command
424424
```powershell
425-
echo '>>> Waiting for GA to start ...'
425+
Write-Output '>>> Waiting for GA Service (RdAgent) to start ...'
426426
while ((Get-Service RdAgent).Status -ne 'Running') { Start-Sleep -s 5 }
427-
while ((Get-Service WindowsAzureTelemetryService).Status -ne 'Running') { Start-Sleep -s 5 }
427+
Write-Output '>>> Waiting for GA Service (WindowsAzureTelemetryService) to start ...'
428+
while ((Get-Service WindowsAzureTelemetryService) -and ((Get-Service WindowsAzureTelemetryService).Status -ne 'Running')) { Start-Sleep -s 5 }
429+
Write-Output '>>> Waiting for GA Service (WindowsAzureGuestAgent) to start ...'
428430
while ((Get-Service WindowsAzureGuestAgent).Status -ne 'Running') { Start-Sleep -s 5 }
429-
echo '>>> Sysprepping VM ...'
430-
if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force} & $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit
431-
while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 5 } else { break } }
431+
Write-Output '>>> Sysprepping VM ...'
432+
if( Test-Path $Env:SystemRoot\system32\Sysprep\unattend.xml ) {
433+
Remove-Item $Env:SystemRoot\system32\Sysprep\unattend.xml -Force
434+
}
435+
& $Env:SystemRoot\System32\Sysprep\Sysprep.exe /oobe /generalize /quiet /quit
436+
while($true) {
437+
$imageState = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State).ImageState
438+
Write-Output $imageState
439+
if ($imageState -eq 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { break }
440+
Start-Sleep -s 5
441+
}
442+
Write-Output '>>> Sysprep complete ...'
432443
```
433444
#### Default Linux deprovision command
434445

0 commit comments

Comments
 (0)