Skip to content

Instantly share code, notes, and snippets.

@alventech
Last active May 30, 2021 09:42
Show Gist options
  • Save alventech/2b9a596a27bebd35e38a5edc865ad1b6 to your computer and use it in GitHub Desktop.
Save alventech/2b9a596a27bebd35e38a5edc865ad1b6 to your computer and use it in GitHub Desktop.
Packer_w10_20h2_SIG
{
"variables": {
"clientAPPID": "",
"clientSecret": "",
"tenantid": "",
"subscriptionid": "",
"image_version" : "",
"WorkingDirectory": "{{env `System_DefaultWorkingDirectory`}}"
},
"builders": [
{
"type": "azure-arm",
"client_id": "{{user `clientAPPID`}}",
"client_secret": "{{user `clientSecret`}}",
"tenant_id": "{{user `tenantid`}}",
"subscription_id": "{{user `subscriptionid`}}",
"shared_image_gallery_destination": {
"subscription": "{{user `subscriptionid`}}",
"resource_group": "Packer",
"gallery_name": "PackerSIG",
"image_name": "Packerimgdef",
"image_version": "{{user `image_version`}}",
"replication_regions": [
"westeurope"
]
},
"managed_image_resource_group_name": "Packer",
"managed_image_name": "wvd-{{isotime \"200601020304\"}}",
"build_resource_group_name" : "wvd-packer-template",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsDesktop",
"image_offer": "Windows-10",
"image_sku": "20h2-evd-g2",
"communicator": "winrm",
"winrm_use_ssl": "true",
"winrm_insecure": "true",
"winrm_timeout": "3m",
"winrm_username": "packer",
"location": "westeruope",
"vm_size": "Standard_DS2_v2",
"async_resourcegroup_delete":true
}
],
"provisioners": [
{
"type": "powershell",
"inline": [
" # NOTE: the following *3* lines are only needed if the you have installed the Guest Agent.",
" while ((Get-Service RdAgent).Status -ne 'Running') { Start-Sleep -s 5 }",
" # while ((Get-Service WindowsAzureTelemetryService).Status -ne 'Running') { Start-Sleep -s 5 }",
" while ((Get-Service WindowsAzureGuestAgent).Status -ne 'Running') { Start-Sleep -s 5 }",
"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 /mode:vm",
"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 } }"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment