windows_2019_hyperv.json

{
  "builders": [
    {
      "boot_wait": "0s",
      "communicator": "winrm",
      "cpus": 2,
      "disk_size": "{{user `disk_size`}}",
      "enable_secure_boot": true,
      "enable_virtualization_extensions": true,
      "floppy_files": [
        "{{user `autounattend`}}",
        "./hyper-v/Windows/scripts/disable-screensaver.ps1",
        "./hyper-v/Windows/scripts/disable-winrm.ps1",
        "./hyper-v/Windows/scripts/enable-winrm.ps1",
        "./hyper-v/Windows/scripts/microsoft-updates.bat",
        "./hyper-v/Windows/scripts/unattend.xml",
        "./hyper-v/Windows/scripts/shutdown_vm.bat",
        "./hyper-v/Windows/scripts/win-updates.ps1"
      ],
      "guest_additions_mode": "disable",
      "iso_checksum": "{{user `iso_checksum`}}",
      "iso_checksum_type": "{{user `iso_checksum_type`}}",
      "iso_url": "{{user `iso_url`}}",
      "memory": 2048,
      "shutdown_command": "a:/shutdown_vm.bat",
      "switch_name": "{{user `hyperv_switchname`}}",
      "type": "hyperv-iso",
      "vm_name": "WindowsServer2019",
      "winrm_password": "{{user `install_password`}}",
      "winrm_timeout": "{{user `winrm_timeout`}}",
      "winrm_username": "{{user `install_user`}}"
    }
  ],
  "provisioners": [
    {
      "type": "file",
      "source": "{{ template_dir }}/scripts/Windows/custom-scripts",
      "destination": "C:/"
    },
    {
        "type": "windows-restart",
        "restart_timeout": "30m"
    },
    {
        "type": "powershell",
        "scripts": [
            "{{ template_dir }}/scripts/Windows/create_appveyor_user.ps1"
        ],
        "environment_vars": [
            "appveyor_user={{user `install_user`}}",
            "appveyor_password={{user `install_password`}}"
        ]
    },
    {
        "type": "powershell",
        "inline":[
            "Write-Host \"Current user: $(whoami)\""
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/init_server.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "windows-restart",
        "restart_timeout": "30m"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_path_utils.ps1",
            "{{ template_dir }}/scripts/Windows/install_powershell_core.ps1",
            "{{ template_dir }}/scripts/Windows/install_powershell_get.ps1",
            "{{ template_dir }}/scripts/Windows/install_7zip.ps1",
            "{{ template_dir }}/scripts/Windows/install_chocolatey.ps1",
            "{{ template_dir }}/scripts/Windows/install_nuget.ps1",
            "{{ template_dir }}/scripts/Windows/install_pstools.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_git.ps1",
            "{{ template_dir }}/scripts/Windows/install_git_lfs.ps1",
            "{{ template_dir }}/scripts/Windows/install_mercurial.ps1",
            "{{ template_dir }}/scripts/Windows/install_subversion.ps1",
            "{{ template_dir }}/scripts/Windows/add_ssh_known_hosts.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_appveyor_build_agent.ps1",
            "{{ template_dir }}/scripts/Windows/enable_autologon.ps1"
        ],
        "environment_vars": [
            "appveyor_user={{user `install_user`}}",
            "appveyor_password={{user `install_password`}}",
            "build_agent_mode={{user `build_agent_mode`}}"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/run_custom_scripts.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    }
  ],
  "variables": {
    "autounattend": "./hyper-v/Windows/answer_files/2019/Autounattend.xml",
    "disk_size": "61440",
    "disk_type_id": "1",
    "headless": "false",
    "hyperv_switchname": "NATSwitch",
    "iso_checksum": "221F9ACBC727297A56674A0F1722B8AC7B6E840B4E1FFBDD538A9ED0DA823562",
    "iso_checksum_type": "sha256",
    "iso_url": "https://software-download.microsoft.com/download/sg/17763.379.190312-0539.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso",
    "manually_download_iso_from": "https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2019",
    "restart_timeout": "5m",
    "winrm_timeout": "2h",
    "install_user": "appveyor",
    "install_password": "appveyor",
    "build_agent_mode": "HyperV"
  }
}