From 8173e5d3ceb9da256e45f7f6d2d77f3d85f05209 Mon Sep 17 00:00:00 2001 From: Oscar Elfving Date: Tue, 26 Sep 2017 11:52:10 +0200 Subject: [PATCH] Updated docs with more robust sysprep script for the windows Azure builder --- website/source/docs/builders/azure.html.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/website/source/docs/builders/azure.html.md b/website/source/docs/builders/azure.html.md index abda2a5f1..0ff741641 100644 --- a/website/source/docs/builders/azure.html.md +++ b/website/source/docs/builders/azure.html.md @@ -216,6 +216,24 @@ The following provisioner snippet shows how to sysprep a Windows VM. Deprovision } ``` +In some circumstances the above isn't enough to reliably know that the sysprep is actually finished generalizing the image, the code below will wait for sysprep to write the image status in the registry and will exit after that. The possible states, in case you want to wait for another state, [are documented here](https://technet.microsoft.com/en-us/library/hh824815.aspx) + +``` json +{ + "provisioners": [ + { + "type": "powershell", + "inline": [ + "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit", + "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 } }" + ] + } + ] +} + + +``` + ### Linux The following provisioner snippet shows how to deprovision a Linux VM. Deprovision should be the last operation executed by a build.