diff --git a/examples/windows/.gitattributes b/examples/windows/.gitattributes new file mode 100644 index 000000000..da5ccf8df --- /dev/null +++ b/examples/windows/.gitattributes @@ -0,0 +1,2 @@ +*.cmd text eol=crlf +*.ps1 text eol=crlf diff --git a/examples/windows/setup/Autounattend.xml b/examples/windows/setup/Autounattend.xml new file mode 100644 index 000000000..9c3d30416 --- /dev/null +++ b/examples/windows/setup/Autounattend.xml @@ -0,0 +1,122 @@ + + + + + en-US + + + + + + + B:\ + + + + + + + true + + + + + + + + + /IMAGE/NAME + Windows 10 Pro + + + true + + + + + + 0 + + + 1 + true + Primary + + + + + + + + + + + false + + + + + + + + 1 + + a:\vmtools.cmd + Always + + + + + + + + en-US + + + + + + 3 + + + + + + + + jetbrains + + jetbrains + true</PlainText> + </Password> + <Group>Administrators</Group> + </LocalAccount> + </LocalAccounts> + </UserAccounts> + + <AutoLogon> + <Enabled>true</Enabled> + <Username>jetbrains</Username> + <Password> + <Value>jetbrains</Value> + <PlainText>true</PlainText> + </Password> + <LogonCount>1</LogonCount> + </AutoLogon> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <Order>1</Order> + <!-- Enable WinRM service --> + <CommandLine>powershell -ExecutionPolicy Bypass -File a:\setup.ps1</CommandLine> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + </FirstLogonCommands> + </component> + </settings> +</unattend> diff --git a/examples/windows/setup/setup.ps1 b/examples/windows/setup/setup.ps1 new file mode 100644 index 000000000..27e65a55e --- /dev/null +++ b/examples/windows/setup/setup.ps1 @@ -0,0 +1,15 @@ +$ErrorActionPreference = "Stop" + +# Switch network connection to private mode +# Required for WinRM firewall rules +$profile = Get-NetConnectionProfile +Set-NetConnectionProfile -Name $profile.Name -NetworkCategory Private + +# Enable WinRM service +winrm quickconfig -quiet +winrm set winrm/config/service '@{AllowUnencrypted="true"}' +winrm set winrm/config/service/auth '@{Basic="true"}' + +# Reset auto logon count +# https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup-autologon-logoncount#logoncount-known-issue +Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoLogonCount -Value 0 diff --git a/examples/windows/setup/vmtools.cmd b/examples/windows/setup/vmtools.cmd new file mode 100644 index 000000000..c6256cc05 --- /dev/null +++ b/examples/windows/setup/vmtools.cmd @@ -0,0 +1,2 @@ +rem Silent mode, basic UI, no reboot +e:\setup64 /s /v "/qb REBOOT=R" diff --git a/examples/windows/windows-10.json b/examples/windows/windows-10.json new file mode 100644 index 000000000..18288dd86 --- /dev/null +++ b/examples/windows/windows-10.json @@ -0,0 +1,49 @@ +{ + "builders": [ + { + "type": "vsphere-iso", + + "vcenter_server": "vcenter.vsphere65.test", + "username": "root", + "password": "jetbrains", + "insecure_connection": "true", + + "vm_name": "example-windows", + "host": "esxi-1.vsphere65.test", + + "guest_os_type": "windows9_64Guest", + + "communicator": "winrm", + "winrm_username": "jetbrains", + "winrm_password": "jetbrains", + + "CPUs": 1, + "RAM": 4096, + "RAM_reserve_all": true, + + "disk_controller_type": "pvscsi", + "disk_size": 32, + "disk_thin_provisioned": true, + + "network_card": "vmxnet3", + + "iso_paths": [ + "[datastore1] ISO/en_windows_10_multi-edition_vl_version_1709_updated_dec_2017_x64_dvd_100406172.iso", + "[datastore1] ISO/VMware Tools/10.2.0/windows.iso" + ], + + "floppy_files": [ + "setup/" + ], + "floppy_img_path": "[datastore1] ISO/VMware Tools/10.2.0/pvscsi-Windows8.flp", + "boot_order": "disk,cdrom" + } + ], + + "provisioners": [ + { + "type": "windows-shell", + "inline": ["dir c:\\"] + } + ] +}