├── .gitignore ├── README.md ├── firstboot.ps1 ├── provision.ps1 ├── windows10 ├── Autounattend.xml ├── packer.json └── vagrantfile.template ├── windows1803 ├── Autounattend.xml ├── packer.json └── vagrantfile.template ├── windows2016 ├── Autounattend.xml ├── packer.json └── vagrantfile.template ├── windows2019 ├── Autounattend.xml ├── packer.json └── vagrantfile.template └── winrm.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /output-vmware/ 3 | /output-vmware-iso/ 4 | /output-vmware-vmx/ 5 | /output-virtualbox/ 6 | /output-virtualbox-iso/ 7 | /output-virtualbox-ovf/ 8 | /*.box 9 | /packer_cache/ 10 | variables.json 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Windows Packer Templates 2 | 3 | Simple [Packer](https://packer.io) templates for creating Windows VMs that support mainstream use cases that can easily be forked and built upon. 4 | 5 | This project makes use of [reusable PowerShell modules](https://github.com/windowsbox/powershellmodules) which allow for others to easily create their own Packer templates without needing to fork a bunch of scripts. Packer templates tend to vary between people and companies but the scripts used by the templates don't vary as much. This is an attempt to separate out the reusable parts from the parts that don't. 6 | 7 | ## Building a Box 8 | 9 | 1. Clone this repository 10 | 2. Install [Packer](http://packer.io) 1.3.4 or newer 11 | 3. Execute Packer (see below) 12 | 13 | You may need to set the `iso_url` and `iso_checksum` variables as some builds expect you to have downloaded an ISO from MSDN and have no default set. A good way to handle this is to use a Packer vars file. You may also need to set the product key code in the Autounattend.xml file depending on the OS installation media chosen. 14 | 15 | The Windows templates support a plain vanilla Windows Vagrant box or a Windows Vagrant box with a bunch of .NET development tools. The examples below are shown without installing the dev tools. 16 | 17 | ### Windows10 18 | 19 | The plain vanilla build creates a Windows 10 box with Windows updates and not much else. 20 | ``` 21 | $ packer build windows10/packer.json 22 | ``` 23 | 24 | ### Windows Server 2016 25 | 26 | The plain vanilla build creates a Windows Server 2016 box with Windows updates and not much else other than Docker. 27 | ``` 28 | $ packer build windows2016/packer.json 29 | ``` 30 | 31 | ### Windows Server 1803 32 | 33 | The plain vanilla build creates a Windows Server 1803 box with Windows updates and not much else other than Docker. 34 | ``` 35 | $ packer build windows1803/packer.json 36 | ``` 37 | 38 | ### Windows Server 2019 39 | 40 | The plain vanilla build creates a Windows Server 2019 box with Windows updates and not much else other than Docker. 41 | ``` 42 | $ packer build windows2019/packer.json 43 | ``` 44 | 45 | ### Development Tools Installation 46 | 47 | The .NET developer Vagrant box includes everything the vanilla box includes plus the following tools: 48 | - Powershell Packagemanagement 49 | - Visual Studio 2017 Community Edition 50 | - Resharper 2017 51 | - Notepad++ 52 | - Google Chrome 53 | - Git for Windows 54 | - Beyond Compare 55 | - Fiddler 4 56 | - SoapUI 57 | - Sql Server Management Studio 58 | - Node JS 59 | - CloudFoundry CLI 60 | - Nuget CLI 61 | 62 | If you want the development tools add `-var devtools=true` to your Packer command line, for example: 63 | ``` 64 | $ packer build -var devtools=true windows10/packer.json 65 | ``` 66 | 67 | ## Development 68 | 69 | ### Local ISOs 70 | 71 | You may want to use a Windows ISO already downloaded because you cleared your Packer cache or for other reasons. The simplest way to use an already existing ISO on your HDD is to serve it up via Python. From the directory where the ISO exists run: `python -m SimpleHTTPServer`. Then override the `iso_url` and `iso_checksum` variables by creating a variables.json file. 72 | 73 | ``` 74 | { 75 | "iso_url": "http://10.0.0.207:8000/en_windows_10_multi-edition_vl_version_1709_updated_dec_2017_x64_dvd_100406172.iso", 76 | "iso_checksum": "f38b0aeae0756e01dcd9b1600de62416e04aa963c72cea30929141f54f1235b3" 77 | } 78 | 79 | ``` 80 | 81 | ``` 82 | $ packer build -var-file windows10/variables.json windows10/packer.json 83 | ``` 84 | 85 | ### Local PowerShell Module Testing 86 | 87 | You may want to test a WindowsBox PowerShell Modules change before committing and publishing it. The quickest way to do that is to make the necessary script changes and then provide the script to the guest VM through the `a:\` drive. Mount the locally modified script by modifying the packer.json and add a floppy files entry, for example: 88 | 89 | ``` 90 | "floppy_files": [ 91 | "../powershellmodules/modules/WindowsBox.WinRM/WindowsBox.WinRM.psm1", 92 | ... 93 | ``` 94 | 95 | Then you need to temporarily change how that module is loaded, from: 96 | ``` 97 | Install-Module WindowsBox.WinRM -Force 98 | ``` 99 | to 100 | ``` 101 | Import-Module -Name a:\WindowsBox.WinRM.psm1 -DisableNameChecking -Force 102 | ``` 103 | 104 | ## Thanks 105 | 106 | This project would not be possible without a lot of work from other projects like [Packer-Windows](https://github.com/joefitzgerald/packer-windows). 107 | 108 | ## Project Values 109 | 110 | - Modern OSs and tools 111 | - Simplicity 112 | - Reuse 113 | -------------------------------------------------------------------------------- /firstboot.ps1: -------------------------------------------------------------------------------- 1 | # Runs before Packer provisioners during first boot 2 | 3 | # We explicitly install nuget because install-module prompts for confirmation even with -Force 4 | Install-PackageProvider -Name Nuget -Force 5 | 6 | # Configure the network to private so we can properly configure WinRM 7 | Install-Module WindowsBox.Network -Force 8 | Set-NetworkToPrivate 9 | 10 | # Kick off the WinRM script that polls for updates to be complete 11 | Start-Job -ScriptBlock { C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -ExecutionPolicy Bypass -File a:\winrm.ps1 } 12 | 13 | # Install all available Windows updates 14 | Install-Module WindowsBox.WindowsUpdates -Force 15 | Install-WindowsUpdates 16 | -------------------------------------------------------------------------------- /provision.ps1: -------------------------------------------------------------------------------- 1 | # Runs after Windows Updates have been applied 2 | 3 | Install-Module WindowsBox.AutoLogon -Force 4 | Install-Module WindowsBox.Compact -Force 5 | Install-Module WindowsBox.Explorer -Force 6 | Install-Module WindowsBox.Hibernation -Force 7 | Install-Module WindowsBox.RDP -Force 8 | Install-Module WindowsBox.UAC -Force 9 | Install-Module WindowsBox.VagrantAccount -Force 10 | Install-Module WindowsBox.VMGuestTools -Force 11 | 12 | Disable-AutoLogon 13 | Disable-UAC 14 | Enable-RDP 15 | Set-ExplorerConfiguration 16 | Disable-Hibernation 17 | Set-VagrantAccount 18 | Install-VMGuestTools 19 | 20 | # Install Docker if the provider is available on this OS 21 | Install-Module DockerMsftProvider -Force 22 | if ((Get-PackageProvider -ListAvailable).Name -Contains "DockerMsftProvider") { 23 | Install-Package -Name docker -ProviderName DockerMsftProvider -Force 24 | } 25 | 26 | if ($env:devtools -eq $true) { 27 | # Install Linux subsystem 28 | Install-Module WindowsBox.DevMode -Force 29 | Enable-DevMode 30 | 31 | # Install chocolatey and use it to install dev tools 32 | Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression 33 | 34 | choco install powershell-packagemanagement -y 35 | choco install visualstudio2019community -y 36 | choco install visualstudio2019-workload-netcoretools -y 37 | choco install visualstudio2019-workload-netweb -y 38 | choco install visualstudio2019-workload-node -y 39 | choco install visualstudio2019-workload-azure -y 40 | choco install visualstudio2019-workload-nativedesktop -y 41 | choco install visualstudio2019-workload-manageddesktop -y 42 | choco install resharper -y 43 | choco install notepadplusplus.install -y 44 | choco install googlechrome -y 45 | choco install git.install -y 46 | choco install beyondcompare -y 47 | choco install fiddler4 -y 48 | choco install sql-server-management-studio -y 49 | choco install nodejs.install -y 50 | choco install cloudfoundry-cli -y 51 | choco install nuget.commandline -y 52 | choco install soapui -y 53 | } 54 | 55 | # Final cleanup 56 | Optimize-DiskUsage 57 | -------------------------------------------------------------------------------- /windows10/Autounattend.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | vagrant-win10 6 | Microsoft 7 | Pacific Standard Time 8 | 9 | 10 | true 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 0 19 | 1 20 | 21 | 22 | 23 | /IMAGE/INDEX 24 | 1 25 | 26 | 27 | OnError 28 | false 29 | 30 | 31 | 32 | true 33 | Vagrant Administrator 34 | Vagrant Inc. 35 | 36 | 37 | 38 | 39 | 40 | 1 41 | Primary 42 | true 43 | 44 | 45 | 46 | 47 | true 48 | false 49 | NTFS 50 | 51 | C 52 | 1 53 | 1 54 | 55 | 56 | 0 57 | true 58 | 59 | OnError 60 | 61 | 62 | 63 | en-US 64 | en-US 65 | en-US 66 | en-US 67 | 68 | 69 | 70 | 71 | en-US 72 | en-US 73 | en-US 74 | en-US 75 | en-US 76 | 77 | 78 | 79 | 80 | 81 | 82 | dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA 83 | false</PlainText> 84 | </Password> 85 | <Description>Vagrant User</Description> 86 | <DisplayName>vagrant</DisplayName> 87 | <Group>Administrators</Group> 88 | <Name>vagrant</Name> 89 | </LocalAccount> 90 | </LocalAccounts> 91 | </UserAccounts> 92 | <AutoLogon> 93 | <Password> 94 | <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value> 95 | <PlainText>false</PlainText> 96 | </Password> 97 | <Enabled>true</Enabled> 98 | <Username>vagrant</Username> 99 | </AutoLogon> 100 | <OOBE> 101 | <ProtectYourPC>1</ProtectYourPC> 102 | </OOBE> 103 | <FirstLogonCommands> 104 | <SynchronousCommand wcm:action="add"> 105 | <CommandLine>powershell -NoLogo -ExecutionPolicy RemoteSigned -File a:\firstboot.ps1</CommandLine> 106 | <Description>Start WinRM</Description> 107 | <Order>1</Order> 108 | </SynchronousCommand> 109 | </FirstLogonCommands> 110 | </component> 111 | </settings> 112 | <settings pass="offlineServicing"> 113 | <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 114 | <EnableLUA>false</EnableLUA> 115 | </component> 116 | </settings> 117 | <cpi:offlineImage cpi:source="wim:c:/extracted/sources/install.wim#Windows 10 Enterprise" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> 118 | </unattend> 119 | -------------------------------------------------------------------------------- /windows10/packer.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "iso_url": "https://software-download.microsoft.com/download/sg/17763.107.101029-1455.rs5_release_svc_refresh_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso", 4 | "iso_checksum": "0278fc4638741f4a1dc85c39ed7fa76bb15fd582165f6ef036e9a9fb2f029351", 5 | "headless": "true", 6 | "devtools": "false" 7 | }, 8 | "builders": [ 9 | { 10 | "type": "virtualbox-iso", 11 | "communicator": "winrm", 12 | "disk_size": 61440, 13 | "floppy_files": [ 14 | "windows10/Autounattend.xml", 15 | "firstboot.ps1", 16 | "winrm.ps1" 17 | ], 18 | "guest_os_type": "Windows10_64", 19 | "headless": "{{user `headless`}}", 20 | "iso_url": "{{user `iso_url`}}", 21 | "iso_checksum_type": "sha256", 22 | "iso_checksum": "{{user `iso_checksum`}}", 23 | "winrm_username": "vagrant", 24 | "winrm_password": "vagrant", 25 | "winrm_timeout": "3h", 26 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 27 | "post_shutdown_delay": "30s", 28 | "guest_additions_mode": "attach", 29 | "vboxmanage": [ 30 | [ 31 | "modifyvm", 32 | "{{.Name}}", 33 | "--memory", 34 | "4096" 35 | ], 36 | [ 37 | "modifyvm", 38 | "{{.Name}}", 39 | "--cpus", 40 | "2" 41 | ], 42 | [ 43 | "modifyvm", 44 | "{{.Name}}", 45 | "--vram", 46 | "32" 47 | ] 48 | ] 49 | } 50 | ], 51 | "provisioners": [ 52 | { 53 | "type": "powershell", 54 | "scripts": ["provision.ps1"], 55 | "environment_vars": ["devtools={{user `devtools`}}"] 56 | }, 57 | { 58 | "type": "windows-restart", 59 | "restart_timeout": "10m" 60 | } 61 | ], 62 | "post-processors": [ 63 | { 64 | "type": "vagrant", 65 | "output": "{{.Provider}}_windows10.box", 66 | "vagrantfile_template": "windows10/vagrantfile.template" 67 | } 68 | ] 69 | } 70 | -------------------------------------------------------------------------------- /windows10/vagrantfile.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.box = "windows10" 8 | config.vm.communicator = "winrm" 9 | config.vm.provider "virtualbox" do |v, override| 10 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /windows1803/Autounattend.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <unattend xmlns="urn:schemas-microsoft-com:unattend"> 3 | <settings pass="specialize"> 4 | <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 5 | <ComputerName>vagrant-win1803</ComputerName> 6 | <RegisteredOrganization>Microsoft</RegisteredOrganization> 7 | <TimeZone>Pacific Standard Time</TimeZone> 8 | </component> 9 | <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 10 | <SkipAutoActivation>true</SkipAutoActivation> 11 | </component> 12 | <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 13 | <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon> 14 | </component> 15 | <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 16 | <IEHardenAdmin>false</IEHardenAdmin> 17 | <IEHardenUser>false</IEHardenUser> 18 | </component> 19 | <component name="Microsoft-Windows-IE-InternetExplorer" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 20 | <SearchScopes> 21 | <Scope wcm:action="add"> 22 | <ScopeDefault>true</ScopeDefault> 23 | <ScopeDisplayName>Google</ScopeDisplayName> 24 | <ScopeKey>Google</ScopeKey> 25 | <ScopeUrl>http://www.google.com/search?q={searchTerms}</ScopeUrl> 26 | </Scope> 27 | </SearchScopes> 28 | <DisableAccelerators>true</DisableAccelerators> 29 | <DisableFirstRunWizard>true</DisableFirstRunWizard> 30 | <Home_Page>about:blank</Home_Page> 31 | </component> 32 | <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 33 | <fDenyTSConnections>false</fDenyTSConnections> 34 | </component> 35 | <component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 36 | <UserAuthentication>0</UserAuthentication> 37 | </component> 38 | <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 39 | <FirewallGroups> 40 | <FirewallGroup wcm:action="add" wcm:keyValue="RemoteDesktop"> 41 | <Active>true</Active> 42 | <Group>Remote Desktop</Group> 43 | <Profile>all</Profile> 44 | </FirewallGroup> 45 | </FirewallGroups> 46 | </component> 47 | <component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 48 | <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon> 49 | </component> 50 | </settings> 51 | <settings pass="windowsPE"> 52 | <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 53 | <ImageInstall> 54 | <OSImage> 55 | <InstallTo> 56 | <DiskID>0</DiskID> 57 | <PartitionID>1</PartitionID> 58 | </InstallTo> 59 | <InstallFrom> 60 | <MetaData wcm:action="add"> 61 | <Key>/IMAGE/INDEX</Key> 62 | <Value>1</Value> 63 | </MetaData> 64 | </InstallFrom> 65 | <WillShowUI>OnError</WillShowUI> 66 | <InstallToAvailablePartition>false</InstallToAvailablePartition> 67 | </OSImage> 68 | </ImageInstall> 69 | <UserData> 70 | <AcceptEula>true</AcceptEula> 71 | <FullName>Vagrant Administrator</FullName> 72 | <Organization>Vagrant Inc.</Organization> 73 | </UserData> 74 | <DiskConfiguration> 75 | <Disk wcm:action="add"> 76 | <CreatePartitions> 77 | <CreatePartition wcm:action="add"> 78 | <Order>1</Order> 79 | <Type>Primary</Type> 80 | <Extend>true</Extend> 81 | </CreatePartition> 82 | </CreatePartitions> 83 | <ModifyPartitions> 84 | <ModifyPartition wcm:action="add"> 85 | <Active>true</Active> 86 | <Extend>false</Extend> 87 | <Format>NTFS</Format> 88 | <Label></Label> 89 | <Letter>C</Letter> 90 | <Order>1</Order> 91 | <PartitionID>1</PartitionID> 92 | </ModifyPartition> 93 | </ModifyPartitions> 94 | <DiskID>0</DiskID> 95 | <WillWipeDisk>true</WillWipeDisk> 96 | </Disk> 97 | <WillShowUI>OnError</WillShowUI> 98 | </DiskConfiguration> 99 | </component> 100 | <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 101 | <InputLocale>en-US</InputLocale> 102 | <SystemLocale>en-US</SystemLocale> 103 | <UILanguage>en-US</UILanguage> 104 | <UserLocale>en-US</UserLocale> 105 | </component> 106 | </settings> 107 | <settings pass="oobeSystem"> 108 | <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 109 | <UserAccounts> 110 | <LocalAccounts> 111 | <LocalAccount wcm:action="add"> 112 | <Password> 113 | <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value> 114 | <PlainText>false</PlainText> 115 | </Password> 116 | <Description>Vagrant User</Description> 117 | <DisplayName>vagrant</DisplayName> 118 | <Group>Administrators</Group> 119 | <Name>vagrant</Name> 120 | </LocalAccount> 121 | </LocalAccounts> 122 | </UserAccounts> 123 | <AutoLogon> 124 | <Password> 125 | <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value> 126 | <PlainText>false</PlainText> 127 | </Password> 128 | <Enabled>true</Enabled> 129 | <Username>vagrant</Username> 130 | </AutoLogon> 131 | <OOBE> 132 | <HideEULAPage>true</HideEULAPage> 133 | <HideLocalAccountScreen>true</HideLocalAccountScreen> 134 | <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> 135 | <HideOnlineAccountScreens>true</HideOnlineAccountScreens> 136 | <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> 137 | <NetworkLocation>Home</NetworkLocation> 138 | <!-- 139 | ProtectYourPC: 140 | 1 Specifies the recommended level of protection for your computer. 141 | 2 Specifies that only updates are installed. 142 | 3 Specifies that automatic protection is disabled. 143 | --> 144 | <ProtectYourPC>3</ProtectYourPC> 145 | </OOBE> 146 | <FirstLogonCommands> 147 | <SynchronousCommand wcm:action="add"> 148 | <CommandLine>powershell -NoLogo -ExecutionPolicy RemoteSigned -File a:\firstboot.ps1</CommandLine> 149 | <Description>Start WinRM</Description> 150 | <Order>1</Order> 151 | </SynchronousCommand> 152 | </FirstLogonCommands> 153 | </component> 154 | </settings> 155 | <settings pass="offlineServicing"> 156 | <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 157 | <EnableLUA>false</EnableLUA> 158 | </component> 159 | </settings> 160 | <cpi:offlineImage cpi:source="wim:d:/sources/install.wim#Windows Server 2016 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi"/> 161 | </unattend> 162 | -------------------------------------------------------------------------------- /windows1803/packer.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "iso_url": "", 4 | "iso_checksum": "", 5 | "headless": "true", 6 | "devtools": "false" 7 | }, 8 | "builders": [ 9 | { 10 | "type": "virtualbox-iso", 11 | "communicator": "winrm", 12 | "disk_size": 61440, 13 | "floppy_files": [ 14 | "windows1803/Autounattend.xml", 15 | "firstboot.ps1", 16 | "winrm.ps1" 17 | ], 18 | "guest_os_type": "Windows2016_64", 19 | "headless": "{{user `headless`}}", 20 | "iso_url": "{{user `iso_url`}}", 21 | "iso_checksum_type": "sha256", 22 | "iso_checksum": "{{user `iso_checksum`}}", 23 | "winrm_username": "vagrant", 24 | "winrm_password": "vagrant", 25 | "winrm_timeout": "3h", 26 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 27 | "post_shutdown_delay": "30s", 28 | "guest_additions_mode": "attach", 29 | "vboxmanage": [ 30 | [ 31 | "modifyvm", 32 | "{{.Name}}", 33 | "--memory", 34 | "4096" 35 | ], 36 | [ 37 | "modifyvm", 38 | "{{.Name}}", 39 | "--cpus", 40 | "2" 41 | ], 42 | [ 43 | "modifyvm", 44 | "{{.Name}}", 45 | "--vram", 46 | "32" 47 | ] 48 | ] 49 | } 50 | ], 51 | "provisioners": [ 52 | { 53 | "type": "powershell", 54 | "scripts": ["provision.ps1"], 55 | "environment_vars": ["devtools={{user `devtools`}}"] 56 | }, 57 | { 58 | "type": "windows-restart", 59 | "restart_timeout": "10m" 60 | } 61 | ], 62 | "post-processors": [ 63 | { 64 | "type": "vagrant", 65 | "output": "{{.Provider}}_windows1803.box", 66 | "vagrantfile_template": "windows1803/vagrantfile.template" 67 | } 68 | ] 69 | } 70 | -------------------------------------------------------------------------------- /windows1803/vagrantfile.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.box = "windows1803" 8 | config.vm.communicator = "winrm" 9 | config.vm.provider "virtualbox" do |v, override| 10 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 11 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /windows2016/Autounattend.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <unattend xmlns="urn:schemas-microsoft-com:unattend"> 3 | <settings pass="specialize"> 4 | <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 5 | <ComputerName>vagrant-win2016</ComputerName> 6 | <RegisteredOrganization>Microsoft</RegisteredOrganization> 7 | <TimeZone>Pacific Standard Time</TimeZone> 8 | </component> 9 | <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 10 | <SkipAutoActivation>true</SkipAutoActivation> 11 | </component> 12 | <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 13 | <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon> 14 | </component> 15 | <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 16 | <IEHardenAdmin>false</IEHardenAdmin> 17 | <IEHardenUser>false</IEHardenUser> 18 | </component> 19 | <component name="Microsoft-Windows-IE-InternetExplorer" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 20 | <SearchScopes> 21 | <Scope wcm:action="add"> 22 | <ScopeDefault>true</ScopeDefault> 23 | <ScopeDisplayName>Google</ScopeDisplayName> 24 | <ScopeKey>Google</ScopeKey> 25 | <ScopeUrl>http://www.google.com/search?q={searchTerms}</ScopeUrl> 26 | </Scope> 27 | </SearchScopes> 28 | <DisableAccelerators>true</DisableAccelerators> 29 | <DisableFirstRunWizard>true</DisableFirstRunWizard> 30 | <Home_Page>about:blank</Home_Page> 31 | </component> 32 | <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 33 | <fDenyTSConnections>false</fDenyTSConnections> 34 | </component> 35 | <component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 36 | <UserAuthentication>0</UserAuthentication> 37 | </component> 38 | <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 39 | <FirewallGroups> 40 | <FirewallGroup wcm:action="add" wcm:keyValue="RemoteDesktop"> 41 | <Active>true</Active> 42 | <Group>Remote Desktop</Group> 43 | <Profile>all</Profile> 44 | </FirewallGroup> 45 | </FirewallGroups> 46 | </component> 47 | <component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 48 | <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon> 49 | </component> 50 | </settings> 51 | <settings pass="windowsPE"> 52 | <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 53 | <ImageInstall> 54 | <OSImage> 55 | <InstallTo> 56 | <DiskID>0</DiskID> 57 | <PartitionID>1</PartitionID> 58 | </InstallTo> 59 | <InstallFrom> 60 | <MetaData wcm:action="add"> 61 | <Key>/IMAGE/NAME</Key> 62 | <Value>Windows Server 2016 SERVERSTANDARD</Value> 63 | </MetaData> 64 | </InstallFrom> 65 | <WillShowUI>OnError</WillShowUI> 66 | <InstallToAvailablePartition>false</InstallToAvailablePartition> 67 | </OSImage> 68 | </ImageInstall> 69 | <UserData> 70 | <AcceptEula>true</AcceptEula> 71 | <FullName>Vagrant Administrator</FullName> 72 | <Organization>Vagrant Inc.</Organization> 73 | </UserData> 74 | <DiskConfiguration> 75 | <Disk wcm:action="add"> 76 | <CreatePartitions> 77 | <CreatePartition wcm:action="add"> 78 | <Order>1</Order> 79 | <Type>Primary</Type> 80 | <Extend>true</Extend> 81 | </CreatePartition> 82 | </CreatePartitions> 83 | <ModifyPartitions> 84 | <ModifyPartition wcm:action="add"> 85 | <Active>true</Active> 86 | <Extend>false</Extend> 87 | <Format>NTFS</Format> 88 | <Label></Label> 89 | <Letter>C</Letter> 90 | <Order>1</Order> 91 | <PartitionID>1</PartitionID> 92 | </ModifyPartition> 93 | </ModifyPartitions> 94 | <DiskID>0</DiskID> 95 | <WillWipeDisk>true</WillWipeDisk> 96 | </Disk> 97 | <WillShowUI>OnError</WillShowUI> 98 | </DiskConfiguration> 99 | </component> 100 | <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 101 | <InputLocale>en-US</InputLocale> 102 | <SystemLocale>en-US</SystemLocale> 103 | <UILanguage>en-US</UILanguage> 104 | <UserLocale>en-US</UserLocale> 105 | </component> 106 | </settings> 107 | <settings pass="oobeSystem"> 108 | <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 109 | <UserAccounts> 110 | <LocalAccounts> 111 | <LocalAccount wcm:action="add"> 112 | <Password> 113 | <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value> 114 | <PlainText>false</PlainText> 115 | </Password> 116 | <Description>Vagrant User</Description> 117 | <DisplayName>vagrant</DisplayName> 118 | <Group>Administrators</Group> 119 | <Name>vagrant</Name> 120 | </LocalAccount> 121 | </LocalAccounts> 122 | </UserAccounts> 123 | <AutoLogon> 124 | <Password> 125 | <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value> 126 | <PlainText>false</PlainText> 127 | </Password> 128 | <Enabled>true</Enabled> 129 | <Username>vagrant</Username> 130 | </AutoLogon> 131 | <OOBE> 132 | <HideEULAPage>true</HideEULAPage> 133 | <HideLocalAccountScreen>true</HideLocalAccountScreen> 134 | <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> 135 | <HideOnlineAccountScreens>true</HideOnlineAccountScreens> 136 | <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> 137 | <NetworkLocation>Home</NetworkLocation> 138 | <!-- 139 | ProtectYourPC: 140 | 1 Specifies the recommended level of protection for your computer. 141 | 2 Specifies that only updates are installed. 142 | 3 Specifies that automatic protection is disabled. 143 | --> 144 | <ProtectYourPC>3</ProtectYourPC> 145 | </OOBE> 146 | <FirstLogonCommands> 147 | <SynchronousCommand wcm:action="add"> 148 | <CommandLine>powershell -NoLogo -ExecutionPolicy RemoteSigned -File a:\firstboot.ps1</CommandLine> 149 | <Description>Start WinRM</Description> 150 | <Order>1</Order> 151 | </SynchronousCommand> 152 | </FirstLogonCommands> 153 | </component> 154 | </settings> 155 | <settings pass="offlineServicing"> 156 | <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 157 | <EnableLUA>false</EnableLUA> 158 | </component> 159 | </settings> 160 | <cpi:offlineImage cpi:source="wim:d:/sources/install.wim#Windows Server 2016 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi"/> 161 | </unattend> 162 | -------------------------------------------------------------------------------- /windows2016/packer.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "iso_url": "http://care.dlservice.microsoft.com/dl/download/1/4/9/149D5452-9B29-4274-B6B3-5361DBDA30BC/14393.0.161119-1705.RS1_REFRESH_SERVER_EVAL_X64FRE_EN-US.ISO", 4 | "iso_checksum": "1ce702a578a3cb1ac3d14873980838590f06d5b7101c5daaccbac9d73f1fb50f", 5 | "headless": "true", 6 | "devtools": "false" 7 | }, 8 | "builders": [ 9 | { 10 | "type": "virtualbox-iso", 11 | "communicator": "winrm", 12 | "disk_size": 61440, 13 | "floppy_files": [ 14 | "windows2016/Autounattend.xml", 15 | "firstboot.ps1", 16 | "winrm.ps1" 17 | ], 18 | "guest_os_type": "Windows2016_64", 19 | "headless": "{{user `headless`}}", 20 | "iso_url": "{{user `iso_url`}}", 21 | "iso_checksum_type": "sha256", 22 | "iso_checksum": "{{user `iso_checksum`}}", 23 | "winrm_username": "vagrant", 24 | "winrm_password": "vagrant", 25 | "winrm_timeout": "3h", 26 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 27 | "post_shutdown_delay": "30s", 28 | "guest_additions_mode": "attach", 29 | "vboxmanage": [ 30 | [ 31 | "modifyvm", 32 | "{{.Name}}", 33 | "--memory", 34 | "4096" 35 | ], 36 | [ 37 | "modifyvm", 38 | "{{.Name}}", 39 | "--cpus", 40 | "2" 41 | ], 42 | [ 43 | "modifyvm", 44 | "{{.Name}}", 45 | "--vram", 46 | "32" 47 | ] 48 | ] 49 | } 50 | ], 51 | "provisioners": [ 52 | { 53 | "type": "powershell", 54 | "scripts": ["provision.ps1"], 55 | "environment_vars": ["devtools={{user `devtools`}}"] 56 | }, 57 | { 58 | "type": "windows-restart", 59 | "restart_timeout": "10m" 60 | } 61 | ], 62 | "post-processors": [ 63 | { 64 | "type": "vagrant", 65 | "output": "{{.Provider}}_windows2016.box", 66 | "vagrantfile_template": "windows2016/vagrantfile.template" 67 | } 68 | ] 69 | } 70 | -------------------------------------------------------------------------------- /windows2016/vagrantfile.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.box = "windows2016" 8 | config.vm.communicator = "winrm" 9 | config.vm.provider "virtualbox" do |v, override| 10 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 11 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /windows2019/Autounattend.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <unattend xmlns="urn:schemas-microsoft-com:unattend"> 3 | <settings pass="specialize"> 4 | <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 5 | <ComputerName>vagrant-win2019</ComputerName> 6 | <RegisteredOrganization>Microsoft</RegisteredOrganization> 7 | <TimeZone>Pacific Standard Time</TimeZone> 8 | </component> 9 | <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 10 | <SkipAutoActivation>true</SkipAutoActivation> 11 | </component> 12 | <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 13 | <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon> 14 | </component> 15 | <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 16 | <IEHardenAdmin>false</IEHardenAdmin> 17 | <IEHardenUser>false</IEHardenUser> 18 | </component> 19 | <component name="Microsoft-Windows-IE-InternetExplorer" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 20 | <SearchScopes> 21 | <Scope wcm:action="add"> 22 | <ScopeDefault>true</ScopeDefault> 23 | <ScopeDisplayName>Google</ScopeDisplayName> 24 | <ScopeKey>Google</ScopeKey> 25 | <ScopeUrl>http://www.google.com/search?q={searchTerms}</ScopeUrl> 26 | </Scope> 27 | </SearchScopes> 28 | <DisableAccelerators>true</DisableAccelerators> 29 | <DisableFirstRunWizard>true</DisableFirstRunWizard> 30 | <Home_Page>about:blank</Home_Page> 31 | </component> 32 | <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 33 | <fDenyTSConnections>false</fDenyTSConnections> 34 | </component> 35 | <component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 36 | <UserAuthentication>0</UserAuthentication> 37 | </component> 38 | <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 39 | <FirewallGroups> 40 | <FirewallGroup wcm:action="add" wcm:keyValue="RemoteDesktop"> 41 | <Active>true</Active> 42 | <Group>Remote Desktop</Group> 43 | <Profile>all</Profile> 44 | </FirewallGroup> 45 | </FirewallGroups> 46 | </component> 47 | <component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 48 | <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon> 49 | </component> 50 | </settings> 51 | <settings pass="windowsPE"> 52 | <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 53 | <ImageInstall> 54 | <OSImage> 55 | <InstallTo> 56 | <DiskID>0</DiskID> 57 | <PartitionID>1</PartitionID> 58 | </InstallTo> 59 | <InstallFrom> 60 | <MetaData wcm:action="add"> 61 | <Key>/IMAGE/NAME</Key> 62 | <Value>Windows Server 2019 SERVERSTANDARD</Value> 63 | </MetaData> 64 | </InstallFrom> 65 | <WillShowUI>OnError</WillShowUI> 66 | <InstallToAvailablePartition>false</InstallToAvailablePartition> 67 | </OSImage> 68 | </ImageInstall> 69 | <UserData> 70 | <AcceptEula>true</AcceptEula> 71 | <FullName>Vagrant Administrator</FullName> 72 | <Organization>Vagrant Inc.</Organization> 73 | </UserData> 74 | <DiskConfiguration> 75 | <Disk wcm:action="add"> 76 | <CreatePartitions> 77 | <CreatePartition wcm:action="add"> 78 | <Order>1</Order> 79 | <Type>Primary</Type> 80 | <Extend>true</Extend> 81 | </CreatePartition> 82 | </CreatePartitions> 83 | <ModifyPartitions> 84 | <ModifyPartition wcm:action="add"> 85 | <Active>true</Active> 86 | <Extend>false</Extend> 87 | <Format>NTFS</Format> 88 | <Label></Label> 89 | <Letter>C</Letter> 90 | <Order>1</Order> 91 | <PartitionID>1</PartitionID> 92 | </ModifyPartition> 93 | </ModifyPartitions> 94 | <DiskID>0</DiskID> 95 | <WillWipeDisk>true</WillWipeDisk> 96 | </Disk> 97 | <WillShowUI>OnError</WillShowUI> 98 | </DiskConfiguration> 99 | </component> 100 | <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 101 | <InputLocale>en-US</InputLocale> 102 | <SystemLocale>en-US</SystemLocale> 103 | <UILanguage>en-US</UILanguage> 104 | <UserLocale>en-US</UserLocale> 105 | </component> 106 | </settings> 107 | <settings pass="oobeSystem"> 108 | <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 109 | <UserAccounts> 110 | <LocalAccounts> 111 | <LocalAccount wcm:action="add"> 112 | <Password> 113 | <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value> 114 | <PlainText>false</PlainText> 115 | </Password> 116 | <Description>Vagrant User</Description> 117 | <DisplayName>vagrant</DisplayName> 118 | <Group>Administrators</Group> 119 | <Name>vagrant</Name> 120 | </LocalAccount> 121 | </LocalAccounts> 122 | </UserAccounts> 123 | <AutoLogon> 124 | <Password> 125 | <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value> 126 | <PlainText>false</PlainText> 127 | </Password> 128 | <Enabled>true</Enabled> 129 | <Username>vagrant</Username> 130 | </AutoLogon> 131 | <OOBE> 132 | <HideEULAPage>true</HideEULAPage> 133 | <HideLocalAccountScreen>true</HideLocalAccountScreen> 134 | <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> 135 | <HideOnlineAccountScreens>true</HideOnlineAccountScreens> 136 | <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> 137 | <NetworkLocation>Home</NetworkLocation> 138 | <!-- 139 | ProtectYourPC: 140 | 1 Specifies the recommended level of protection for your computer. 141 | 2 Specifies that only updates are installed. 142 | 3 Specifies that automatic protection is disabled. 143 | --> 144 | <ProtectYourPC>3</ProtectYourPC> 145 | </OOBE> 146 | <FirstLogonCommands> 147 | <SynchronousCommand wcm:action="add"> 148 | <CommandLine>powershell -NoLogo -ExecutionPolicy RemoteSigned -File a:\firstboot.ps1</CommandLine> 149 | <Description>Start WinRM</Description> 150 | <Order>1</Order> 151 | </SynchronousCommand> 152 | </FirstLogonCommands> 153 | </component> 154 | </settings> 155 | <settings pass="offlineServicing"> 156 | <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 157 | <EnableLUA>false</EnableLUA> 158 | </component> 159 | </settings> 160 | <cpi:offlineImage cpi:source="wim:d:/sources/install.wim#Windows Server 2016 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi"/> 161 | </unattend> 162 | -------------------------------------------------------------------------------- /windows2019/packer.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "iso_url": "https://software-download.microsoft.com/download/sg/17763.253.190108-0006.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso", 4 | "iso_checksum": "57faf4a2ea4484cfdf5e964c539313c061c4d9cac474e723d60405f2ea02d570", 5 | "headless": "true", 6 | "devtools": "false" 7 | }, 8 | "builders": [ 9 | { 10 | "type": "virtualbox-iso", 11 | "communicator": "winrm", 12 | "disk_size": 61440, 13 | "floppy_files": [ 14 | "windows2019/Autounattend.xml", 15 | "firstboot.ps1", 16 | "winrm.ps1" 17 | ], 18 | "guest_os_type": "Windows2016_64", 19 | "headless": "{{user `headless`}}", 20 | "iso_url": "{{user `iso_url`}}", 21 | "iso_checksum_type": "sha256", 22 | "iso_checksum": "{{user `iso_checksum`}}", 23 | "winrm_username": "vagrant", 24 | "winrm_password": "vagrant", 25 | "winrm_timeout": "3h", 26 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 27 | "post_shutdown_delay": "30s", 28 | "guest_additions_mode": "attach", 29 | "vboxmanage": [ 30 | [ 31 | "modifyvm", 32 | "{{.Name}}", 33 | "--memory", 34 | "4096" 35 | ], 36 | [ 37 | "modifyvm", 38 | "{{.Name}}", 39 | "--cpus", 40 | "2" 41 | ], 42 | [ 43 | "modifyvm", 44 | "{{.Name}}", 45 | "--vram", 46 | "32" 47 | ] 48 | ] 49 | } 50 | ], 51 | "provisioners": [ 52 | { 53 | "type": "powershell", 54 | "scripts": ["provision.ps1"], 55 | "environment_vars": ["devtools={{user `devtools`}}"] 56 | }, 57 | { 58 | "type": "windows-restart", 59 | "restart_timeout": "10m" 60 | } 61 | ], 62 | "post-processors": [ 63 | { 64 | "type": "vagrant", 65 | "output": "{{.Provider}}_windows2019.box", 66 | "vagrantfile_template": "windows2019/vagrantfile.template" 67 | } 68 | ] 69 | } 70 | -------------------------------------------------------------------------------- /windows2019/vagrantfile.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.box = "windows2019" 8 | config.vm.communicator = "winrm" 9 | config.vm.provider "virtualbox" do |v, override| 10 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 11 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /winrm.ps1: -------------------------------------------------------------------------------- 1 | # This script runs on boot until Windows Updates complete 2 | # then it enables WinRM 3 | 4 | function WinUpdatesComplete() { 5 | $f = "C:\Windows\Temp\win-updates.log" 6 | if (!(Test-Path $f -PathType Leaf)) { 7 | return $false 8 | } 9 | return (select-string -Path $f -Pattern "Done Installing Windows Updates") -ne $null 10 | } 11 | 12 | $RegistryKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" 13 | $RegistryEntry = "CheckUpdatesComplete" 14 | 15 | # Configure this script to run again if a reboot happens 16 | Set-ItemProperty -Path $RegistryKey -Name $RegistryEntry -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -ExecutionPolicy Bypass -File a:\winrm.ps1" 17 | 18 | # Block until we find that Windows Updates have completed 19 | while (!(WinUpdatesComplete)) { 20 | Start-Sleep -s 30 21 | } 22 | 23 | # Done Installing Windows Updates, remove this script from running on boot 24 | $prop = (Get-ItemProperty $RegistryKey).$RegistryEntry 25 | if ($prop) { 26 | Remove-ItemProperty -Path $RegistryKey -Name $RegistryEntry -ErrorAction SilentlyContinue 27 | } 28 | 29 | # Enable WinRM insecurely for local Packer provisioners 30 | Install-Module WindowsBox.WinRM -Force 31 | Enable-InsecureWinRM 32 | --------------------------------------------------------------------------------