Skip to content

Commit 8606236

Browse files
authored
Update build-image-with-packer.md
It is generally not sufficient to call sysprep, and then exit. To ensure a reliable build, one should wait for sysprep to complete before returning from the provisioner. I updated the document to match the advice I give in the Azure examples, and in Packer's own documentation.
1 parent 01cc8fa commit 8606236

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

articles/virtual-machines/windows/build-image-with-packer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ Create a file named *windows.json* and paste the following content. Enter your o
107107
"type": "powershell",
108108
"inline": [
109109
"Add-WindowsFeature Web-Server",
110-
"if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
111-
"& $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /shutdown /quiet"
110+
"& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
111+
"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 10 } else { break } }"
112112
]
113113
}]
114114
}

0 commit comments

Comments
 (0)