├── .gitignore
├── LICENSE
├── README-rsync.md
├── README-shutdown_command.md
├── README-stefanscherer.md
├── README.md
├── answer_files
└── 10
│ ├── Autounattend.xml
│ └── orginal-Autounattend.xml
├── build_windows_10.sh
├── floppy
├── PinTo10.exe
├── ReadMe.txt
└── WindowsPowershell.lnk
├── iso
└── README.md
├── scripts
├── .gitignore
├── chef.bat
├── chocolatey.bat
├── chocopacks.bat
├── compact.bat
├── compile-dotnet-assemblies.bat
├── create-domain.ps1
├── debloat-windows.ps1
├── dis-updates.bat
├── dis-updates.ps1
├── disable-auto-logon.bat
├── disable-screensaver.ps1
├── disable-tasks.bat
├── disable-winrm.ps1
├── docker
│ ├── 10
│ │ └── install-containers-feature.ps1
│ ├── 2016
│ │ └── install-containers-feature.ps1
│ ├── add-docker-group.ps1
│ ├── chocolatey-and-tools.ps1
│ ├── disable-windows-defender.ps1
│ ├── docker-pull.ps1
│ ├── enable-winrm.ps1
│ ├── install-docker.ps1
│ ├── open-docker-insecure-port.ps1
│ ├── open-docker-swarm-ports.ps1
│ ├── remove-docker-key-json.ps1
│ ├── set-winrm-automatic.ps1
│ └── set-winrm-delayed-automatic.ps1
├── enable-rdp.bat
├── enable-remote-desktop.bat
├── enable-uac.bat
├── enable-winrm.bat
├── enable-winrm.ps1
├── fixnetwork.ps1
├── hotfix-KB2552055.bat
├── hotfix-KB2842230.bat
├── installnet4.bat
├── microsoft-updates.bat
├── openssh.ps1
├── pin-powershell.bat
├── prepare-for-upload-vhd-image.ps1
├── puppet-enterprise.bat
├── puppet.bat
├── rsync.bat
├── salt.bat
├── set-powerplan.ps1
├── set-winrm-automatic.bat
├── sysprep.bat
├── uac-enable.bat
├── unattend.xml
├── vagrant-ssh.bat
├── vm-guest-tools.bat
├── wait-for-desktop-file.ps1
├── wait-for-tiworker.ps1
├── win-7-update-2016-convenience-rollup.ps1
├── win-7-update-2019-03-servicing-stack.ps1
├── win-7-update-2019-07-update-rollup.ps1
├── win-7-update-2019-09-servicing-stack.ps1
├── win-7-update-2019-09-sha2.ps1
├── win-7-update-2019-10-update-rollup.ps1
├── win-7-update-net48.ps1
├── win-7-update-powershell-5.1.ps1
├── win-7-update-sp1.ps1
└── win-updates.ps1
├── vagrantfile-windows_10.template
├── validate.sh
├── windows_10.json
└── windows_10.json.original
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /iso/*
3 | !/iso/README.md
4 | /output-hyperv-iso/
5 | /output-vmware/
6 | /output-vmware-iso/
7 | /output-vmware-vmx/
8 | /output-virtualbox/
9 | /output-virtualbox-iso/
10 | /output-virtualbox-ovf/
11 | /*.box
12 | /packer_cache/
13 | *.log
14 | *~
15 | *.swp
16 | /output/
17 | *.webm
18 | tmp
19 | /issues/
20 | *.iso
21 | path-to.vmx
22 | README-secret.md
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2014 Joe Fitzgerald
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README-rsync.md:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | # How to enable RSync for Windows Templates
8 |
9 | ## Introduction
10 |
11 | This document explains how to install RSync into the Windows boxes to be able to use Vagrant's synced folder type `rsync`. Read the [Vagrant Docs](https://docs.vagrantup.com/v2/synced-folders/rsync.html) for more details and the additional vagrant commands.
12 |
13 | ## Prerequisites
14 |
15 | ### SSH
16 |
17 | To use `rsync` in the Windows boxes you also will need that SSH is installed and enabled. At the time of writing OpenSSH will always be installed to make the packer build work. This is part of the `Autounattend.xml` answer files.
18 |
19 | In the future SSH might disappear from default installation as packer will be able to communicate through WinRM with the Windows box. For rsync you then have to add the `scripts/openssh.ps1` again to have OpenSSH up and running.
20 |
21 | ## Installation
22 |
23 | To install `rsync` in the Windows boxes you have to add the `./scripts/rsync.bat` script to the packer template's shell provisioner scripts as shown in this example:
24 |
25 | ```json
26 | "provisioners": [
27 | {
28 | "type": "shell",
29 | "remote_path": "/tmp/script.bat",
30 | "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
31 | "scripts": [
32 | "./scripts/vm-guest-tools.bat",
33 | "./scripts/chef.bat",
34 | "./scripts/vagrant-ssh.bat",
35 | "./scripts/compile-dotnet-assemblies.bat",
36 | "./scripts/rsync.bat",
37 | "./scripts/compact.bat"
38 | ]
39 | },
40 | ```
41 |
42 | The script also creates a symlink so that the folder `/vagrant` could be used in the Vagrantfile to sync files to `C:\vagrant`. So the example from the Vagrant documentation works without any changes.
43 |
44 | ## Enable RSync in a Vagrantfile
45 |
46 | The following is an example of using RSync to sync a folder into a Windows box. Please notice that we have to forward the SSH port as it will not be forwarded automatically at the moment.
47 | ```ruby
48 | # -*- mode: ruby -*-
49 | # vi: set ft=ruby :
50 |
51 | VAGRANTFILE_API_VERSION = "2"
52 |
53 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
54 | config.vm.box = "windows_2012_r2"
55 |
56 | config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/"
57 |
58 | config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true
59 |
60 | config.vm.provider "virtualbox" do |vb|
61 | vb.gui = true
62 | end
63 | end
64 | ```
65 |
66 | If you want to sync into another directory of the Windows box, use the Cygwin path prefix `/cygdrive/c` as shown in this example:
67 |
68 | ```ruby
69 | config.vm.synced_folder '.', "/cygdrive/c/vagrant-rsync",
70 | type: "rsync",
71 | rsync__auto: "true",
72 | rsync__exclude: [".git/",".vagrant/"],
73 | id: "vagrant"
74 | ```
75 |
--------------------------------------------------------------------------------
/README-shutdown_command.md:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | # Packer shutdown_command
8 | There is an alternative for the normal Windows shutdown command.
9 | Normally we use something like this to shutdown the VM in packer.
10 |
11 | ```json
12 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
13 | ```
14 |
15 | Replace it with
16 |
17 | ```json
18 | "shutdown_command": "c:/windows/system32/sysprep/sysprep.exe /generalize /oobe /quiet /shutdown /unattend:a:/unattend.xml",
19 | ```
20 |
21 | Also make sure to add the `./scripts/unattend.xml` file to the `floppy_files`.
22 |
23 | On the first `vagrant up` the box will boot with an out-of-box-experience (OOBE)
24 |
25 | ## Windows Server 2016
26 |
27 | On newer systems like Windows 10 and Windows Server 2016 this shutdown_command is not enough.
28 | We also have to stop the "tiledatamodelsvc" service to make sysprep work. So we use a small cmd script.
29 |
30 | ```json
31 | "shutdown_command": "a:/sysprep.bat"
32 | ```
33 |
34 | Also make sure to add the files `./scripts/unattend.xml` and `./scripts/sysprep.bat` to the `floppy_files`.
35 |
36 | On the first `vagrant up` the box will boot with an out-of-box-experience (OOBE)
37 |
--------------------------------------------------------------------------------
/README-stefanscherer.md:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | # Windows Templates for Packer
8 |
9 | [](https://ci.appveyor.com/project/StefanScherer/packer-windows)
10 |
11 | ### Introduction
12 |
13 | This repository contains Windows templates that can be used to create boxes for
14 | Vagrant using Packer ([Website](https://www.packer.io))
15 | ([Github](https://github.com/mitchellh/packer)).
16 |
17 | This repo is a modified fork of the popular
18 | [joefitzgerald/packer-windows](https://github.com/joefitzgerald/packer-windows)
19 | repo.
20 |
21 | Some of my enhancements are:
22 |
23 | * Support of fullscreen Retina display on a MacBook Pro.
24 | * WinRM, no more OpenSSH
25 |
26 | ### Packer Version
27 |
28 | [Packer](https://github.com/mitchellh/packer/blob/master/CHANGELOG.md) `1.3.3` is recommended.
29 |
30 | ### Windows Versions
31 |
32 | The following Windows versions are known to work (built with VMware Fusion Pro
33 | 11.0.2):
34 |
35 | * Windows 10
36 | * Windows 10 1809 -> Vagrant Cloud box [StefanScherer/windows_10](https://app.vagrantup.com/StefanScherer/boxes/windows_10)
37 | * Windows 10 Insider
38 | * Windows Server 2016 Desktop -> Vagrant Cloud box [StefanScherer/windows_2016](https://app.vagrantup.com/StefanScherer/boxes/windows_2016)
39 | * Windows Server 2019 Desktop -> Vagrant Cloud box [StefanScherer/windows_2019](https://app.vagrantup.com/StefanScherer/boxes/windows_2019)
40 | * Windows Server Core
41 | * Windows Server 2016 without and with Docker -> Vagrant Cloud box [StefanScherer/windows_2016_docker](https://app.vagrantup.com/StefanScherer/boxes/windows_2016_docker)
42 | * Windows Server 2019 without and with Docker -> Vagrant Cloud box [StefanScherer/windows_2019_docker](https://app.vagrantup.com/StefanScherer/boxes/windows_2019_docker)
43 | * Windows Server 1709, 1803, 1809, 1903, and 1909 all without and with Docker
44 | * Windows Server InsiderPreview Semi-Annual without and with Docker
45 |
46 | You may find other packer template files, but older versions of Windows doesn't
47 | work so nice with a Retina display.
48 |
49 | ### Windows Editions
50 |
51 | All Windows Server versions are defaulted to the Server Standard edition. You
52 | can modify this by editing the Autounattend.xml file, changing the
53 | `ImageInstall`>`OSImage`>`InstallFrom`>`MetaData`>`Value` element (e.g. to
54 | Windows Server 2012 R2 SERVERDATACENTER).
55 |
56 | To retrieve the correct ImageName from an ISO file use the following two commands.
57 |
58 | ```
59 | PS C:\> Mount-DiskImage -ImagePath C:\iso\Windows_InsiderPreview_Server_2_16237.iso
60 | PS C:\> Get-WindowsImage -ImagePath e:\sources\install.wim
61 |
62 | ImageIndex : 1
63 | ImageName : Windows Server 2016 SERVERSTANDARDACORE
64 | ImageDescription : Windows Server 2016 SERVERSTANDARDACORE
65 | ImageSize : 7,341,507,794 bytes
66 |
67 | ImageIndex : 2
68 | ImageName : Windows Server 2016 SERVERDATACENTERACORE
69 | ImageDescription : Windows Server 2016 SERVERDATACENTERACORE
70 | ImageSize : 7,373,846,520 bytes
71 | ```
72 |
73 | ### Product Keys
74 |
75 | The `Autounattend.xml` files are configured to work correctly with trial ISOs
76 | (which will be downloaded and cached for you the first time you perform a
77 | `packer build`). If you would like to use retail or volume license ISOs, you
78 | need to update the `UserData`>`ProductKey` element as follows:
79 |
80 | * Uncomment the `...` element
81 | * Insert your product key into the `Key` element
82 |
83 | If you are going to configure your VM as a KMS client, you can use the product
84 | keys at http://technet.microsoft.com/en-us/library/jj612867.aspx. These are the
85 | default values used in the `Key` element.
86 |
87 | ### Using existing ISOs
88 |
89 | If you have already downloaded the ISOs or would like to override them, set
90 | these additional variables:
91 |
92 | * iso_url - path to existing ISO
93 | * iso_checksum - md5sum of existing ISO (if different)
94 |
95 | ```
96 | packer build -var 'iso_url=./server2016.iso' .\windows_2016.json
97 | ```
98 |
99 | ### Windows Updates
100 |
101 | The scripts in this repo will install all Windows updates – by default – during
102 | Windows Setup. This is a _very_ time consuming process, depending on the age of
103 | the OS and the quantity of updates released since the last service pack. You
104 | might want to do yourself a favor during development and disable this
105 | functionality, by commenting out the `WITH WINDOWS UPDATES` section and
106 | uncommenting the `WITHOUT WINDOWS UPDATES` section in `Autounattend.xml`:
107 |
108 | ```xml
109 |
110 |
111 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 -AutoStart
112 | Install OpenSSH
113 | 99
114 | true
115 |
116 |
117 |
118 |
137 |
138 | ```
139 |
140 | Doing so will give you hours back in your day, which is a good thing.
141 |
142 | ### Windows 7 support
143 |
144 | Windows 7 is going out of support in January 2020, and the scripts for building Windows 7 machines are only
145 | sporadically maintained.
146 |
147 | Windows 7 was first released in 2009. This means there are a lot of updates available for Windows 7,
148 | and running Windows Updates on a Windows 7 box using the mechanism described above takes an extremely long time.
149 |
150 | The Windows 7 templates therefore take a slightly different approach, first installing Service Pack 1,
151 | updating the servicing stack and then installing the latest update rollup, .NET 4.8 and PowerShell 5.1.
152 | Finally, any missing updates are installed using Ansible.
153 |
154 | This means you'll need to install Ansible on your machine if you want to run the Windows 7 scripts.
155 | You can [install ansible on a Linux machine](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html).
156 |
157 | If you want to run these scripts on a Windows machine, you can try to run Ansible in cygwin or Bash on Ubuntu on Windows.
158 | Alternatively, you can disable the `ansible` steps in the `windows_7.json` file. Make sure to manually run
159 | Windows Update if you do!
160 |
161 | ### WinRM
162 |
163 | These boxes use WinRM. There is no OpenSSH installed.
164 |
165 | ### Hyper-V Support
166 |
167 | If you are running Windows 10, Windows Server 2016 or later, then you can also use these packerfiles to build
168 | a Hyper-V virtual machine. I have the ISO already downloaded to save time, and
169 | only have Hyper-V installed on my laptop, so I run:
170 |
171 | ```
172 | packer build --only hyperv-iso -var 'hyperv_switchname=Ethernet' -var 'iso_url=./server2016.iso' .\windows_2016_docker.json
173 | ```
174 |
175 | Where `Ethernet` is the name of my default Hyper-V Virtual Switch. You then can use this box with Vagrant to spin up a Hyper-V VM.
176 |
177 | #### Generation 2 VMs
178 |
179 | Some of these images use Hyper-V "Generation 2" VMs to enable the latest features and faster booting. However, an extra manual step is needed to put the needed files into ISOs because Gen2 VMs don't support virtual floppy disks.
180 |
181 | * `windows_server_insider.json`
182 | * `windows_server_insider_docker.json`
183 | * `windows_10_insider.json`
184 |
185 | Before running `packer build`, be sure to run `./make_unattend_iso.ps1` first. Otherwise the build will fail on a missing ISO file
186 |
187 | ```none
188 | hyperv-iso output will be in this color.
189 |
190 | 1 error(s) occurred:
191 |
192 | * Secondary Dvd image does not exist: CreateFile ./iso/windows_server_insider_unattend.iso: The system cannot find the file specified.
193 | ```
194 |
195 | ### KVM/qemu support
196 |
197 | If you are using Linux and have KVM/qemu configured, you can use these packerfiles to build a KVM virtual machine.
198 | To build a KVM/qemu box, first make sure:
199 |
200 | * You are a member of the kvm group on your machine. You can list the groups you are member of by running `groups`. It should
201 | include the `kvm` group. If you're not a member, run `sudo usermod -aG kvm $(whoami)` to add yourself.
202 | * You have downloaded [the iso image with the Windows drivers for paravirtualized KVM/qemu hardware](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso).
203 | You can do this from the command line: `wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O virtio-win.iso`.
204 |
205 | You can use the following sample command to build a KVM/qemu box:
206 |
207 | ```
208 | packer build --only=qemu --var virtio_win_iso=./virtio-win.iso ./windows_2019_docker.json
209 | ```
210 |
211 | ### Parallels support
212 |
213 | In case you're using Parallels, you can now build the `Windows Server 2019 with Docker` VM.
214 |
215 | Prerequisites:
216 | * Parallels Pro or Business, version 11 and up.
217 | * Vagrant Parallels Provider: https://github.com/Parallels/vagrant-parallels
218 |
219 | You can use the following sample command to build a Parallels VM:
220 |
221 | ```
222 | packer build --only=parallels-iso windows_2019_docker.json
223 | ```
224 |
225 |
226 | The Parallels builder config turns `efi boot` off in order to use the same answer file like all the other builders. If you find you need to turn `efi boot` on then make sure to adjust the appropriate answer file, especially the section regarding the partitioning of the disk.
227 | If you need to further customize the VM, consult the documentation at https://www.packer.io/docs/builders/parallels-iso.html.
228 |
229 | ### Using .box Files With Vagrant
230 |
231 | The generated box files include a Vagrantfile template that is suitable for use
232 | with Vagrant 1.7.4+, but the latest version is always recommended.
233 |
234 | Example Steps for Hyper-V:
235 |
236 | ```
237 | vagrant box add windows_2016_docker windows_2016_docker_hyperv.box
238 | vagrant init windows_2016_docker
239 | vagrant up --provider hyperv
240 | ```
241 |
242 | ### Contributing
243 |
244 | Pull request are welcome!
245 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Now that multiple Vagrant boxes are available for Windows 10
12 | (e.g. Vagrant Cloud repository [`baunegaard/win10pro-en`][35]),
13 | I have no need to build my own Vagrant box.
14 | You can find my much easier replacement approach in my Github repository
15 | [`jeffskinnerbox/windows-10-pro`][36].
16 |
17 |
18 | ----
19 |
20 |
21 | # Vagrant Box for Windows 10
22 | Vagrant boxes for all the variants of Linux are plentiful since
23 | this OS is (generally) open source,
24 | but a product like MS Windows is different.
25 | Microsoft doesn't generally give you Vagrant boxes for its product.
26 | So I decided to create my own Windows 10 base box for Vagrant,
27 | then on top of this base, build a Windows OS box with the Office Suite & Visio pre-installed.
28 |
29 | Vagrant's documentation seems to discourse you from creating your own base boxes.
30 | I suspect this is because box creation is really a task done with your virtual machine tool kit,
31 | which is a non-trivial process to perform,
32 | and you can save a lot of time simply using a base box someone else has created.
33 |
34 | You'll need a [hypervisor][25] ([Virtualbox][01] in my case),
35 | [Vagrant][02] and a Windows 10 [ISO file or disc][04].
36 | I purchased mine from Microsoft but you can use an [Windows 10 evaluation version][03].
37 |
38 | The basic prerequisites in creating your Windows 10 base box are:
39 | install VirtualBox, Vagrant, Packer, RDP client xfreerdp,
40 | and obtain Microsoft 10 OS ISO Image.
41 |
42 | Some good sources of information are:
43 |
44 | * [How to Build a Vagrant Box from Scratch](https://www.youtube.com/watch?v=edoDx8bzU4M)
45 | * [How to create you own vagrant base boxes](http://kamalim.github.io/blogs/how-to-create-you-own-vagrant-base-boxes/)
46 | * [Create a Vagrant Base Box (VirtualBox)](https://oracle-base.com/articles/vm/create-a-vagrant-base-box-virtualbox)
47 |
48 | * [Reusable Windows VMs with Vagrant](https://rendered-obsolete.github.io/2019/02/04/vagrant.html)
49 | * [First steps with Windows on Vagrant](https://akrabat.com/first-steps-with-windows-on-vagrant/)
50 | * [Creating a Windows 10 Base Box for Vagrant with VirtualBox](https://huestones.co.uk/2015/08/creating-a-windows-10-base-box-for-vagrant-with-virtualbox/)
51 | * [Create Windows 10 Vagrant Base Box](https://softwaretester.info/create-windows-10-vagrant-base-box/)
52 |
53 | * [Create Windows Machine Builds With Packer](https://blog.ipswitch.com/create-windows-machine-builds-with-packer)
54 | * [Jeff Geerling's Vagrant Box Packer Builds](https://github.com/geerlingguy/packer-boxes)
55 | * [Create Vagrant boxes with Packer for rapid IT environment builds](https://searchitoperations.techtarget.com/tutorial/Create-Vagrant-boxes-with-Packer-for-rapid-IT-environment-builds)
56 | * [Packer-Windows10](https://github.com/luciusbono/Packer-Windows10)
57 | * [Vagrant - 9 - Windows boxes with Vagrant and Packer](https://www.youtube.com/watch?v=EgqQMDw4T4Q)
58 |
59 |
60 | -----
61 |
62 |
63 | # Tools Being Used
64 |
65 | ## VirtualBox
66 | [VirtualBox][09] is a [full virtualization][07] x86 / AMD64 / Intel64 hardware architecture
67 | (contrast this with [hardware-assisted virtualization][08]).
68 | It creates a virtual machine (VM), aka an emulation of a computer system.
69 | Virtual machines (VM) behave like a separate computer system,
70 | complete with virtual hardware devices.
71 | The VM runs as a process in a window on your current operating system.
72 | You can boot an operating system installer disc (or live CD) inside the virtual machine,
73 | and the operating system will be “tricked” into thinking it’s running on a real computer.
74 | It will install and run just as it would on a real, physical machine.
75 |
76 | ## Vagrant
77 | [Vagrant][20] is a tool that offers a simple and easy to use
78 | command-line client for managing virtual environments created by the most popular
79 | virtualization platforms like VirtualBox, VMWare, etc.
80 | Its great for standup new software solutions for testing without disrupting your working system.
81 | You can build and manage virtual machine environments in a single workflow.
82 |
83 | Vagrant has an easy-to-use workflow, makes automation easy,
84 | and lowers development environment setup time.
85 | Machines are provisioned on top of VirtualBox, VMware, AWS, or any other provider.
86 | Then, industry-standard provisioning tools such as
87 | shell scripts, Chef, or Puppet, can automatically install
88 | and configure software on the virtual machine.
89 |
90 | ## Packer
91 | The creation of a Vagrant box starts with the creation of VM using virtualization tool like VirtualBox.
92 | This is often a manual process, using a GUI or CLI,
93 | and is very different for all the virtualization tools on the market (e.g. VitrualBox, VMWare, etc.).
94 | Unfortunately, this doesn't fit the modern paradigm of [infrastructure as code][14].
95 |
96 | To overcome this, the creates of Vagrant, [HasiCorp][15], offer a tool called [Packer][16].
97 | [Why Use Packer][11]?
98 | Packer embraces modern configuration management automates the creation of any type of machine image.
99 | Packer is an open source tool for creating identical 'machine images'
100 | for multiple virtualization tools from a single source configuration.
101 | Packer runs on every major operating system, and creates machine images for multiple platforms in parallel.
102 | Packer does not replace [configuration management][17] tools like Ansible, Chef, or Puppet.
103 | In fact, when building images,
104 | Packer is able to use configuration management tools to install software onto the image.
105 | Packer lets you build Virtual Machine images for different providers from one JSON file.
106 | You can use the same file and commands to build an image on AWS, Digital Ocean VirtualBox and Vagrant.
107 | This makes it possible to use exactly the same system for development which you then create in production.
108 |
109 | >**NOTE:** A 'machine image' is a single static unit that contains a pre-configured operating system
110 | >and installed software which is used to quickly create new running machines.
111 | >Machine image formats change for each platform.
112 | >Some examples include AMIs for an AWS EC2,VMDK/VMX files for VMware, OVF exports for VirtualBox, etc.
113 |
114 |
115 | ----
116 |
117 |
118 | # Building Vagrant Windows 10 Base Box
119 | While Vagrant can support supports Windows and Linux VMs,
120 | creating an OS image is vastly different between the two.
121 | I will show here on how use Packer & Vagrant to create a Windows 10 VM.
122 | Here are the steps you need to do:
123 |
124 | Prerequisites:
125 |
126 | 1. Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads),
127 | [Vagrant](https://www.vagrantup.com/docs/installation/),
128 | [Packer](https://www.packer.io/intro/getting-started/install.html)
129 | 2. Install RDP Client [xfreerdp](http://www.freerdp.com/)
130 | 3. Obtain a [Windows 10 ISO file][03]
131 |
132 | >**NOTE:** See the following for some guidance:
133 | >
134 | >* VirtualBox - ["How to Install VirtualBox 7.0 on Ubuntu 22.04"][30] and ["Fix apt-get update 'the following signatures couldn’t be verified because the public key is not available'"][31].
135 | >* Packer - ["Install Packer"][32] and ["`packer fix` Command"][34]
136 | >* RDP Client `xfreerdp` - ["Configure FreeRDP client on my Ubuntu server to access other desktops"][33]
137 |
138 | ## Step 1: Install the Prerequisites
139 | Install VirtualBox, Vagrant, Packer, and the RDP client `xfreerdp`.
140 | VirtualBox and Vagrant installation are likely familiar tools but
141 | I'll provide install instructions for Packer and the RDP client here.
142 |
143 | ### Step 1A: Installing Packer
144 | Packer is likely to be the least fimilar of the required tools,
145 | so here is a short installation tutorial ([source][26]).
146 | Packer may be installed from a pre-compiled binary or from source.
147 | The easy and recommended method for all users is binary installation method.
148 | Check the latest release of Packer on the [Downloads page][19].
149 | Then download the recent version for your platform.
150 | In my case:
151 |
152 | ```bash
153 | # download version 1.5.1 for ubuntu
154 | cd ~/tmp
155 | export VER="1.5.1"
156 | wget https://releases.hashicorp.com/packer/${VER}/packer_${VER}_linux_amd64.zip
157 |
158 | # uncompress the download file
159 | unzip packer_${VER}_linux_amd64.zip
160 |
161 | # move the packer binary into your path
162 | sudo mv packer /usr/local/bin
163 |
164 | # verify the install is working
165 | $ packer --help
166 | Usage: packer [--version] [--help] []
167 |
168 | Available commands are:
169 | build build image(s) from template
170 | console creates a console for testing variable interpolation
171 | fix fixes templates from old versions of packer
172 | inspect see components of a template
173 | validate check that a template is valid
174 | version Prints the Packer version
175 | ```
176 |
177 | Packer uses builders (sometimes called a template)
178 | to generate images and create machines for various platforms from templates.
179 | A builder is a configuration file used to define what image is built and its format is JSON.
180 | You can see a [full list of supported builders and their templates][05].
181 | A builder has the following three main parts.
182 |
183 | 1. **variables** – Where you define custom variables.
184 | 2. **builders** – Where you mention all the required builder parameters.
185 | 3. **provisioners** – Where you can integrate a shell script,
186 | ansible play or a chef cookbook for configuring a required application.
187 |
188 | ### Step 1B: Install RDP Client
189 | Vagrant will not SSH into a Windows VM, but instead,
190 | needs to use Microsoft's Remote Desktop Protocol (RDP).
191 | Vagrant requires either the RDP client's `xfreerdp` or `rdesktop`
192 | in order to connect into the Vagrant environment.
193 |
194 | ```bash
195 | # install vagrant supported rdp client xfreerdp
196 | sudo apt-get -y install freerdp2-x11
197 | ```
198 |
199 | >**NOTE:** [Remmina][12] is Ubuntu's default remote desktop client but Vagrant can't use it.
200 | >Remmina supports multiple network protocols in an integrated & consistent user interface.
201 | >The protocols currently supported are:
202 | >RDP (Remote Desktop Protocol), VNC (Virtual Network Computing),
203 | >NX (NoMachine NX / FreeNX), XDMCP (X Display Manager Control Protocol)
204 | >and SSH (Secure Shell / Open SSH).
205 |
206 | ## Step 2: Create Packer Template for Windows 10
207 | The [Stefan Scherer][13] [packer-window GitHub repository][21]
208 | contains Packer templates that can be used to create a wide verity of Windows boxes for Vagrant.
209 | Stefan uses this repository to generate a
210 | [Vagrant boxes for multiple Windows OS][23] on [Vagrant Cloud][24].
211 |
212 | We'll clone Stefan's GitHub repository,
213 | and then strip-out the things we don't need for our Windows 10 Vagrant box.
214 |
215 | ```bash
216 | # change to your target directory
217 | cd ~/src/vagrant-machines
218 |
219 | # clone the repository
220 | git clone https://github.com/StefanScherer/packer-windows.git ms-windows
221 | cd ~/src/vagrant-machines/ms-windows
222 |
223 | # remove what you don't need for windows 10
224 | rm -f *windows_[7-8]* *windows_20*
225 | rm -f *windows_server* *insider* *docker*
226 | rm -f make_unattend_iso.ps1 Dockerfile CHANGELOG.md appveyor.yml AZURE.md build_windows_10.ps1 README-ami.md test.ps1 upload-vhd.ps1 fix.sh
227 | rm -r -f ansible bin nested test
228 |
229 | # remove un-needed answer files
230 | rm -r -f ./answer_files/20* ./answer_files/8* ./answer_files/7* ./answer_files/server*
231 | rm -r -f 10_insider 10_insider_uefi
232 |
233 | # modify the README.md file
234 | mv README.md README-stefanscherer.md
235 |
236 | # modify the packer template for windows 10
237 | sed -i 's/vagrant-windows-10-preview/Windows 10 Base Box/' vagrantfile-windows_10.template
238 | sed -i 's/windows_10_preview/windows10base/' vagrantfile-windows_10.template
239 |
240 | # modify the build script for windows 10
241 | cat <<'EOF' > build_windows_10.sh
242 | #!/bin/bash
243 | packer build --only=virtualbox-iso --var iso_url=./iso/windows-10-pro-012020.iso windows_10.json
244 | EOF
245 |
246 | # validate the packer template
247 | packer validate --only=vmware-iso --only=virtualbox-iso windows_10.json
248 | # OR
249 | ./validate.sh
250 | ```
251 |
252 | Now make these modifications your starting point for your
253 | version of this repository:
254 |
255 | ```bash
256 | # destroy the old repository, but not .gitignore
257 | rm -r -f .git .gitattributes
258 |
259 | # create a new repository and check in the changes
260 | git init
261 | git add --all
262 | git commit -m"jeffskinnerbox version of StefanScherer GitHub repository"
263 | ```
264 |
265 | >**NOTE:** The Packer scripts will install all Windows updates during Windows Setup.
266 | >This is a very time consuming process and you might want to disable this.
267 | >The [StefanScherer GitHub repository][18] shows how to do this.
268 |
269 | >**NOTE:** Using StefanScherer's GitHub scripts,
270 | >StefanScherer maintains a[Windows 10 Vagant box on the HashiCorp Vagrant Cloud][22].
271 | >If you prefer, you could use StefanScherer's instead of building your own Vagrant box,
272 | >but this box doesn't have a Microsoft license.
273 |
274 | ## Step 4: Download Microsoft Provided ISO File
275 | You'll need to place a ISO file in `~/src/vagrant-machines/ms-windows/iso`
276 | containing your MS Windows 10 OS,
277 | where the Packer build script `windows_10.json` will pick it up.
278 | You have three options for getting this ISO file:
279 |
280 | 1. You can download an evaluation copy of Windows 10 x64 Enterprise ([here][03]).
281 | Ultimately, you might need a purchase a licensed version of Windows 10
282 | but this evaluation copy gives you 90 days of free use.
283 | 2. **This is what I did:**
284 | Purchase a physical version of MS Windows 10 Pro
285 | and create your own [ISO 9660 filesystem image][04].
286 | To do this, you can use [`genisoimage`][05] & some advice from [here][06].
287 | `genisoimage` is a command-line tool for creating ISO file.
288 | You find more details in the `~/src/vagrant-machines/ms-windows/iso/README.md` file.
289 | 3. Download an active Windows 10 Disc Image ([here][10]) which requires a Product Key.
290 | You can't use the product key from the purchase referenced above, but instead,
291 | purchase the product key from Microsoft.
292 |
293 | To create the ISO image for my MS Windows 10 ISO file destine for my VirtualBox vagrant box,
294 | I used the following command:
295 |
296 | ```bash
297 | # create iso image suitable for ms-windows from the usb drive filesystem
298 | genisoimage -no-emul-boot -b boot/etfsboot.com -boot-load-seg 0x07C0 -boot-load-size 8 -iso-level 2 -udf -joliet -R -D -N -V "VirtualBox-CD" -relaxed-filenames -o ./iso/windows-10-pro-020120.iso /media/jeff/WINDOWS10/x64
299 | ```
300 |
301 | Now lets checkout the newly create ISO file to make sure it is in good working order:
302 |
303 | ```bash
304 | # create a mount point and mount the iso file
305 | mkdir /media/jeff/VirtualBox-CD
306 | sudo mount -o loop ~/src/vagrant-machines/ms-windows/iso/windows-10-pro-020120.iso /media/jeff/VirtualBox-CD
307 |
308 | # verify the mounting
309 | df -H
310 | ls -l /media/jeff/VirtualBox-CD/
311 |
312 | # to unmount the iso file
313 | sudo umount /media/jeff/VirtualBox-CD/
314 | ```
315 |
316 | Create a check sum that will be used within the `packer` tool.
317 |
318 | ```bash
319 | # generate a checksum for purchased physical version of ms windows 10 pro
320 | cd ~/src/vagrant-machines/ms-windows/iso
321 | $ sha256sum windows-10-pro-020120.iso
322 | 5a8969afcf5c49faf3d8f7f0bddfd5517453248dec47f125a61c93f538d08625 windows-10-pro-020120.iso
323 | ```
324 |
325 | I found these articles critical to my understanding of how to use `genisoimage`:
326 |
327 | * [How to create a Windows bootable CD with mkisofs](http://www.g-loaded.eu/2007/04/25/how-to-create-a-windows-bootable-cd-with-mkisofs/)
328 | * [How to Create Bootable Windows 10 image in Debian?](https://unix.stackexchange.com/questions/312488/how-to-create-bootable-windows-10-image-in-debian)
329 |
330 | ## Step 5: Modify the Answer File
331 | Since you need to provide a Product Key during the Packer build process,
332 | edit the `~/src/vagrant-machines/ms-windows/answer_files/10/Autounattend.xml`
333 | and updated it with the key that came with your ISO file.
334 | Procedures on how to make these edits are within the comments of the file.
335 |
336 | ## Step 6: Build the Vagrant Box Using Packer
337 | Now, start the build process using Packer to create a Vagrant box:
338 |
339 | ```bash
340 | # build the vagrant box using purchased physical version of ms windows 10 pro
341 | packer build --only=virtualbox-iso -var 'iso_url=./iso/windows-10-pro-020120.iso' -var 'iso_checksum=5a8969afcf5c49faf3d8f7f0bddfd5517453248dec47f125a61c93f538d08625' windows_10.json
342 |
343 | # OR - assuming you updated the script
344 | #./build_windows_10.sh
345 | ```
346 |
347 | The building of the Windows 10 OS will take several hours (its Microsoft after all).
348 | You'll know when the Packer build is complete when the script terminate
349 | and trace messages are no long printed.
350 |
351 | >**NOTE:** Early in the boot-up of the VirtualBox,
352 | >I get prompted for "Select the operating system you want to install"
353 | >and a menu from the MS Windows install script.
354 | >Appears there is a missing response in the
355 | >`~/src/vagrant-machines/ms-windows/answer_files/10` file.
356 |
357 | ## Step 7: Build the Vagrant Box
358 | Now that `packer` has completed building the box,
359 | next we want to make this box available for use by adding it to our list of available boxes.
360 | The follow commands adds the new box to the list of currently available boxes.
361 |
362 | ```bash
363 | # install the vagrant box in your local repository
364 | #vagrant box add windows10base ./windows_10_virtualbox.box
365 | vagrant box add --name windows10base ./windows_10_virtualbox.box
366 |
367 | # check to see the box is in the local repository
368 | vagrant box list
369 |
370 | # remove the built box now that its in the repository
371 | rm windows_10_virtualbox.box
372 | ```
373 |
374 | Now you have the box and you can use it like any other box
375 | by referencing it in a `Vagrantfile` for a new build.
376 |
377 | If you wise to remove the box from the local repository,
378 | use the command `vagrant box remove windows10base`.
379 |
380 | ## Step 8: Test the Build
381 | Now lets test if the newly created Vagrant box in fact works.
382 | You can login into the VM using “vagrant” as user name and “vagrant” as a password,
383 | but first we need to initialize our test environment:
384 |
385 | ```bash
386 | # create your test environment
387 | mkcd ~/tmp/test-windows-10
388 |
389 | # initialize the vagrant environment
390 | vagrant init
391 | cp ~/src/vagrant-machines/ms-windows/vagrantfile-windows_10.template Vagrantfile
392 |
393 | # may want to run this to clear out certificates
394 | xfreerdp /u:vagrant /p:vagrant /v:127.0.0.1:3389
395 |
396 | # bring up the vm (first issues will take long time, in typical Microsoft fashion)
397 | vagrant up
398 |
399 | # log into the ms windows 10 vm
400 | vagrant rdp
401 | ```
402 |
403 | >**NOTE:** When doing the `vagrant up`, you might hang on the trace message
404 | >"==> Windows 10 Base Box: Also, verify that the firewall is open to allow RDP connections."
405 | >This is most like due to an old certificates in `~/.config/freerdp/known_hosts2`.
406 | >You can see this clearly if you run `xfreerdp /u:vagrant /p:vagrant /v:127.0.0.1:3389`.
407 | >Clean out the old certificate and your should then be able to use `vagrant rdp` without problem.
408 |
409 | Check that the Product Key has in fact been installed.
410 | Check the status of the license by opening the
411 | **Settings** app and click **Update & Security**.
412 | Open **Activation** and it should state the product is already activated.
413 |
414 | Another method is to open a PowerShell Admin window session and enter the following commandline:
415 |
416 | ```bash
417 | # print the product key
418 | wmic path softwareLicensingService get OA3xOriginalProductKey
419 | ```
420 |
421 | >**NOTE:** You can only have a single active license for MS Windows,
422 | >so you might not get a positive response to having an active license.
423 | >Check out the article ["How to Transfer your Windows 10 License to a New Computer"][27]
424 | >to resolve this issue.
425 |
426 | ## Step 9: Access Host Filesystem
427 | Within MS Windows 10,
428 | open a Explorer window and select **Network**
429 | and you'll notice "File sharing is turned off...".
430 | Click to change it.
431 | This will give you access to the Vagrant host computer filesystem.
432 |
433 | Once satisfied all is working well, run the following to clear out test environment:
434 |
435 | ```bash
436 | # remove local version of the vagrant box
437 | vagrant destroy
438 | rm -f -r ~/tmp/test-windows-10
439 | ```
440 |
441 |
442 | ----
443 |
444 |
445 | # Build Box with MS Office, Visio, and TurboTax
446 | I also have software downloads for MS Office, Visio, and a TurboTax CD.
447 | I want to install them on top of the Windows 10 base box.
448 | My MS Office & Visio files are in `~/src/vagrant-machines/ms-windows` and called:
449 |
450 | ```
451 | # office pro and visio install programs located in ~/src/vagrant-machines/ms-windows/iso
452 | Setup.Def.en-US_Professional2019Retail_0d3ef3f9-ae67-4b97-a856-fff4d491ba2c_TX_PR_Platform_def_.exe
453 | Setup.Def.en-US_VisioStd2019Retail_0738b055-a809-4718-9a19-bfc2ec63bb9f_TX_PR_Platform_def_.exe
454 | ```
455 |
456 | My TurboTax is on a CD-ROM and I want to load that software directly from the CD.
457 | To do this, I need the CD/DVD optical reader on my host computer to share with the MS Windoes 10 guest VM.
458 |
459 | ## Step 1: Create Your Windows 10 VM Vagrantfile
460 | Using the Vagrant base box we just create,
461 | create a VM instance for your working version of MS Windows 10.
462 |
463 | ```bash
464 | # make diretory where your ms window 10 will reside
465 | mkdir ~/src/vagrant-machines/windows-10
466 | cd ~/src/vagrant-machines/windows-10
467 |
468 | # initialize the vagrant environment
469 | cp ~/src/vagrant-machines/ms-windows/vagrantfile-windows_10.template Vagrantfile
470 | ```
471 |
472 | With this, you can create an envirnment that will look like the base box.
473 | The remaining steps converts this into your working Windows 10 envirnment.
474 |
475 | ## Step 2: Access CD/DVD Reader
476 | To allow the VM to access the host's optical drive,
477 | add the following to the Vagrantfile:
478 |
479 | ```
480 | .
481 | .
482 | # add access to host optical drive
483 | config.vm.provider :virtualbox do |v, override|
484 | v.customize ["storagectl", :id, "--name", "SATA Controller", "--add", "sata", "--controller", "IntelAHCI"]
485 | v.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", "0", "--device", "0", "--type", "dvddrive", "--hotpluggable", "on", "--medium", "host:/dev/sr0"]
486 | end
487 | .
488 | .
489 | ```
490 |
491 | To derive the Vagrantfile update,
492 | I experimented with provisioning VirtualBox directly using [VBoxManage][29],
493 | settling on the following as working code:
494 |
495 | ```bash
496 | # get the list of VMs that are running
497 | $ vboxmanage list runningvms
498 | "rsyslog-test_default_1581097326775_97773" {5bf0edd8-8fde-48fa-9532-f9cfdae98ae0}
499 | "windows-10_Windows10BaseBox_1581212590774_74597" {856f4ebb-3f51-4138-a51a-2091bf2ab296}
500 |
501 | # add a virtual SATA controller and point to physical DVD drive
502 | VM="windows-10_Windows10BaseBox_1581212590774_74597"
503 | vboxmanage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
504 | vboxmanage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type dvddrive --hotpluggable on --medium host:/dev/sr0
505 | ```
506 |
507 | Sources used to understand what was needed:
508 |
509 | * [Create VirtualBox VM from the command line](http://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html)
510 | * [Vagrant - Adding a second hard drive](https://everythingshouldbevirtual.com/virtualization/vagrant-adding-a-second-hard-drive/)
511 | * [Add an empty optical drive to Oracle VirtualBox instance with the Vagrantfile](https://medium.com/@njeremymiller/add-an-empty-optical-drive-to-oracle-virtualbox-instance-with-the-vagrantfile-523e8e9114be)
512 | * [How to add storage settings to Vagrant file?](https://stackoverflow.com/questions/21986511/how-to-add-storage-settings-to-vagrant-file)
513 | * [FIX FOR VBOXMANAGE: ERROR: COULD NOT FIND A CONTROLLER NAMED ‘SATA’ ERROR](https://www.minvolai.com/fix-for-vboxmanage-error-could-not-find-a-controller-named-sata-error/)
514 |
515 | ## Step 3: Install Office Pro and Visio
516 | I could use a Vagrantfile to do this install but my skills in PowerShell
517 | are nearly non-existent.
518 | Therefore, I'll be doing the old fashion manual way.
519 | I will login into the Windows 10 VM and install the Office Pro and Visio packages manually.
520 |
521 | First thing we must do is create links to these package in our working directory on the host computer
522 | so we can do the install.
523 |
524 | ```bash
525 | # symbolic link to office pro setup executable
526 | ln -s ~/src/vagrant-machines/ms-windows/iso/Setup.Def.en-US_Professional2019Retail_0d3ef3f9-ae67-4b97-a856-fff4d491ba2c_TX_PR_Platform_def_.exe setup_office_pro.exe
527 |
528 | # symbolic link to visio setup executable
529 | ln -s ~/src/vagrant-machines/ms-windows/iso/Setup.Def.en-US_VisioStd2019Retail_0738b055-a809-4718-9a19-bfc2ec63bb9f_TX_PR_Platform_def_.exe setup_visio.exe
530 |
531 | # symbolic link to file containing product keys
532 | ln -s ~/src/vagrant-machines/ms-windows/iso/README-secret.md README-secret.md
533 | ```
534 |
535 | Now lets bring up the VM:
536 |
537 | ```bash
538 | # bring up the vm (first issues will take long time, in typical Microsoft fashion)
539 | vagrant up
540 | ```
541 |
542 | Next, login to the VM,
543 | establish access to your working directory on the Vagrant host machine,
544 | and then execute the setup programs.
545 |
546 | 1. Execute `vagrant rdp &` with the host machine.
547 | 2. Within MS Windows 10,
548 | open a Explorer window and select **Network**
549 | and you'll notice "File sharing is turned off...".
550 | Click to change it.
551 | This will give you access to the Vagrant host computer filesystem.
552 | 3. Within Explorer, select **Network** > **VBOXSVR** > **\\VBOXSVR\vagrant**
553 | 4. Execute `setup_office_pro.exe` and `setup_visio.exe` to install Office Pro and Visio.
554 | 5. To install TurboTax, place the CD in the optical drive and execute the setup script.
555 |
556 | >**NOTE:** You may want to run this
557 | >`xfreerdp /u:vagrant /p:vagrant /v:127.0.0.1:3389`
558 | >to clear out certificates problems if vagrant rdp fails.
559 |
560 | ## Step 4: Apply Product Keys
561 | Check the status of the license by opening the
562 | **Settings** app and click **Update & Security**.
563 | Open **Activation** and it should state the product is already activated.
564 |
565 | ## Step 5: Make It Another Box
566 | I could decide to create a new Vagrant base box from this new VM using [this method][28],
567 | but I see no purpose at this time.
568 |
569 |
570 |
571 | [01]:https://www.virtualbox.org/
572 | [02]:https://www.vagrantup.com/
573 | [03]:https://www.microsoft.com/en-us/evalcenter/evaluate-windows-10-enterprise
574 | [04]:https://en.wikipedia.org/wiki/ISO_9660
575 | [05]:http://www.tuxarena.com/static/tut_iso_cli.php
576 | [06]:https://thomas-cokelaer.info/blog/2011/05/how-to-create-an-iso-image-from-a-folder-linux/
577 | [07]:https://www.virtualbox.org/wiki/Virtualization
578 | [08]:https://en.wikipedia.org/wiki/Hardware-assisted_virtualization
579 | [09]:https://www.virtualbox.org/
580 | [10]:https://www.microsoft.com/en-us/software-download/windows10ISO
581 | [11]:https://www.packer.io/intro/why.html
582 | [12]:https://remmina.org/
583 | [13]:https://stefanscherer.github.io/
584 | [14]:https://en.wikipedia.org/wiki/Infrastructure_as_code
585 | [15]:https://www.hashicorp.com/
586 | [16]:https://www.packer.io/
587 | [17]:https://www.ansible.com/use-cases/configuration-management
588 | [18]:https://github.com/StefanScherer/packer-windows#windows-updates
589 | [19]:https://packer.io/downloads.html
590 | [20]:https://www.vagrantup.com/
591 | [21]:https://github.com/StefanScherer/packer-windows
592 | [22]:https://app.vagrantup.com/StefanScherer/boxes/windows_10
593 | [23]:https://app.vagrantup.com/StefanScherer/
594 | [24]:https://app.vagrantup.com/boxes/search
595 | [25]:https://en.wikipedia.org/wiki/Hypervisor
596 | [26]:https://computingforgeeks.com/how-to-install-and-use-packer/
597 | [27]:https://www.groovypost.com/howto/transfer-windows-10-license-new-pc/
598 | [28]:https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one
599 | [29]:https://docs.oracle.com/cd/E97728_01/E97727/html/vboxmanage-intro.html
600 | [30]:https://tecadmin.net/how-to-install-virtualbox-on-ubuntu-22-04/
601 | [31]:https://chrisjean.com/fix-apt-get-update-the-following-signatures-couldnt-be-verified-because-the-public-key-is-not-available/
602 | [32]:https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli
603 | [33]:https://stackoverflow.com/questions/58215340/configure-freerdp-client-on-my-ubuntu-server-to-access-other-desktops
604 | [34]:https://developer.hashicorp.com/packer/docs/commands/fix
605 | [35]:https://app.vagrantup.com/baunegaard/boxes/win10pro-en/versions/1.4.0
606 | [36]:https://github.com/jeffskinnerbox/windows-10-pro
607 | [37]:
608 | [38]:
609 |
610 |
--------------------------------------------------------------------------------
/answer_files/10/Autounattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
16 |
17 |
18 | E:\viostor\w10\amd64
19 |
20 |
21 |
22 | E:\NetKVM\w10\amd64
23 |
24 |
25 |
26 | E:\Balloon\w10\amd64
27 |
28 |
29 |
30 | E:\pvpanic\w10\amd64
31 |
32 |
33 |
34 | E:\qemupciserial\w10\amd64
35 |
36 |
37 |
38 | E:\qxldod\w10\amd64
39 |
40 |
41 |
42 | E:\vioinput\w10\amd64
43 |
44 |
45 |
46 | E:\viorng\w10\amd64
47 |
48 |
49 |
50 | E:\vioscsi\w10\amd64
51 |
52 |
53 |
54 | E:\vioserial\w10\amd64
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | 1
65 | Primary
66 | true
67 |
68 |
69 |
70 |
71 | false
72 | NTFS
73 | C
74 | 1
75 | 1
76 |
77 |
78 |
79 | 0
80 | true
81 |
82 | OnError
83 |
84 |
85 | true
86 | Vagrant
87 | Vagrant
88 |
89 |
101 |
102 |
103 |
108 |
109 | 6N74X-CB2YP-BMM8X-HWB34-KBT6T
110 | Never
111 |
112 |
113 |
114 |
115 |
116 | 0
117 | 1
118 |
119 | OnError
120 | false
121 |
122 |
123 | /IMAGE/NAME
124 | Windows 10 Enterprise Evaluation
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 | en-US
133 |
134 | en-US
135 | en-US
136 | en-US
137 | en-US
138 | en-US
139 |
140 |
141 |
142 |
143 | false
144 |
145 |
146 |
147 |
148 | en-US
149 | en-US
150 | en-US
151 | en-US
152 |
153 |
154 |
155 |
156 | vagrant
157 | true
158 |
159 |
160 |
161 |
162 | vagrant
163 | true
164 |
165 | Vagrant User
166 | vagrant
167 | administrators
168 | vagrant
169 |
170 |
171 |
172 |
173 | true
174 | true
175 | Home
176 | 1
177 |
178 |
179 |
180 | vagrant
181 | true
182 |
183 | vagrant
184 | true
185 |
186 |
187 |
188 | cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
189 | Set Execution Policy 64 Bit
190 | 1
191 | true
192 |
193 |
194 | C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
195 | Set Execution Policy 32 Bit
196 | 2
197 | true
198 |
199 |
200 | cmd.exe /c reg add "HKLM\System\CurrentControlSet\Control\Network\NewNetworkWindowOff"
201 | Network prompt
202 | 3
203 | true
204 |
205 |
206 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\fixnetwork.ps1
207 | Fix public network
208 | 4
209 | true
210 |
211 |
212 | C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\disable-winrm.ps1
213 | Disable WinRM
214 | 5
215 | true
216 |
217 |
218 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f
219 | 6
220 | Show file extensions in Explorer
221 |
222 |
223 | %SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f
224 | 7
225 | Enable QuickEdit mode
226 |
227 |
228 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f
229 | 8
230 | Show Run command in Start Menu
231 |
232 |
233 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f
234 | 9
235 | Show Administrative Tools in Start Menu
236 |
237 |
238 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f
239 | 10
240 | Zero Hibernation File
241 |
242 |
243 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f
244 | 11
245 | Disable Hibernation Mode
246 |
247 |
248 | cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
249 | 12
250 | Disable password expiration for vagrant user
251 |
252 |
253 | %SystemRoot%\System32\reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d "vagrant" /f
254 | 13
255 | Enable AutoLogon
256 |
257 |
258 | %SystemRoot%\System32\reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f
259 | 14
260 | Enable AutoLogon
261 |
262 |
263 |
270 |
271 |
272 |
273 | cmd.exe /c a:\microsoft-updates.bat
274 | 98
275 | Enable Microsoft Updates
276 |
277 |
278 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\disable-screensaver.ps1
279 | Disable Screensaver
280 | 99
281 | true
282 |
283 |
284 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1
285 | Install Windows Updates
286 | 100
287 | true
288 |
289 |
290 |
291 | false
292 |
293 |
294 |
295 |
296 |
297 | false
298 |
299 |
300 | vagrant-10
301 | Pacific Standard Time
302 |
303 |
304 |
305 | true
306 |
307 |
308 |
309 |
310 |
--------------------------------------------------------------------------------
/answer_files/10/orginal-Autounattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
16 |
17 |
18 | E:\viostor\w10\amd64
19 |
20 |
21 |
22 | E:\NetKVM\w10\amd64
23 |
24 |
25 |
26 | E:\Balloon\w10\amd64
27 |
28 |
29 |
30 | E:\pvpanic\w10\amd64
31 |
32 |
33 |
34 | E:\qemupciserial\w10\amd64
35 |
36 |
37 |
38 | E:\qxldod\w10\amd64
39 |
40 |
41 |
42 | E:\vioinput\w10\amd64
43 |
44 |
45 |
46 | E:\viorng\w10\amd64
47 |
48 |
49 |
50 | E:\vioscsi\w10\amd64
51 |
52 |
53 |
54 | E:\vioserial\w10\amd64
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | 1
65 | Primary
66 | true
67 |
68 |
69 |
70 |
71 | false
72 | NTFS
73 | C
74 | 1
75 | 1
76 |
77 |
78 |
79 | 0
80 | true
81 |
82 | OnError
83 |
84 |
85 | true
86 | Vagrant
87 | Vagrant
88 |
89 |
101 |
102 |
103 | 2FMYP-QCY43-QR9VK-WTVCK
104 | Never
105 |
106 |
107 |
108 |
109 |
110 | 0
111 | 1
112 |
113 | OnError
114 | false
115 |
116 |
117 | /IMAGE/NAME
118 | Windows 10 Enterprise Evaluation
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 | en-US
127 |
128 | en-US
129 | en-US
130 | en-US
131 | en-US
132 | en-US
133 |
134 |
135 |
136 |
137 | false
138 |
139 |
140 |
141 |
142 | en-US
143 | en-US
144 | en-US
145 | en-US
146 |
147 |
148 |
149 |
150 | vagrant
151 | true
152 |
153 |
154 |
155 |
156 | vagrant
157 | true
158 |
159 | Vagrant User
160 | vagrant
161 | administrators
162 | vagrant
163 |
164 |
165 |
166 |
167 | true
168 | true
169 | Home
170 | 1
171 |
172 |
173 |
174 | vagrant
175 | true
176 |
177 | vagrant
178 | true
179 |
180 |
181 |
182 | cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
183 | Set Execution Policy 64 Bit
184 | 1
185 | true
186 |
187 |
188 | C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
189 | Set Execution Policy 32 Bit
190 | 2
191 | true
192 |
193 |
194 | cmd.exe /c reg add "HKLM\System\CurrentControlSet\Control\Network\NewNetworkWindowOff"
195 | Network prompt
196 | 3
197 | true
198 |
199 |
200 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\fixnetwork.ps1
201 | Fix public network
202 | 4
203 | true
204 |
205 |
206 | C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\disable-winrm.ps1
207 | Disable WinRM
208 | 5
209 | true
210 |
211 |
212 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f
213 | 6
214 | Show file extensions in Explorer
215 |
216 |
217 | %SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f
218 | 7
219 | Enable QuickEdit mode
220 |
221 |
222 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f
223 | 8
224 | Show Run command in Start Menu
225 |
226 |
227 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f
228 | 9
229 | Show Administrative Tools in Start Menu
230 |
231 |
232 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f
233 | 10
234 | Zero Hibernation File
235 |
236 |
237 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f
238 | 11
239 | Disable Hibernation Mode
240 |
241 |
242 | cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
243 | 12
244 | Disable password expiration for vagrant user
245 |
246 |
247 | %SystemRoot%\System32\reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d "vagrant" /f
248 | 13
249 | Enable AutoLogon
250 |
251 |
252 | %SystemRoot%\System32\reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f
253 | 14
254 | Enable AutoLogon
255 |
256 |
257 |
264 |
265 |
266 |
267 | cmd.exe /c a:\microsoft-updates.bat
268 | 98
269 | Enable Microsoft Updates
270 |
271 |
272 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\disable-screensaver.ps1
273 | Disable Screensaver
274 | 99
275 | true
276 |
277 |
278 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1
279 | Install Windows Updates
280 | 100
281 | true
282 |
283 |
284 |
285 | false
286 |
287 |
288 |
289 |
290 |
291 | false
292 |
293 |
294 | vagrant-10
295 | Pacific Standard Time
296 |
297 |
298 |
299 | true
300 |
301 |
302 |
303 |
304 |
--------------------------------------------------------------------------------
/build_windows_10.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 |
4 | # build the vagrant box using purchased physical version of ms windows 10 pro
5 | #packer build --only=virtualbox-iso -var 'iso_url=./iso/windows-10-pro-012020.iso' -var 'iso_checksum=07a055219c89f20ec5a5edf50399d09c0fbbe7c9cae173363c8f96cbb6f803e1' windows_10.json
6 |
7 | # build the vagrant box using downloaded evaluation copy of windows 10 x64 enterprise
8 | #packer build --only=virtualbox-iso -var 'iso_url=./iso/18363.418.191007-0143.19h2_release_svc_refresh_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso' -var 'iso_checksum=9ef81b6a101afd57b2dbfa44d5c8f7bc94ff45b51b82c5a1f9267ce2e63e9f53' windows_10.json
9 |
10 | # using https://www.microsoft.com/en-us/software-download/windows10ISO
11 | # build the vagrant box using downloaded windows 10 disk image
12 | packer build --only=virtualbox-iso -var 'iso_url=./iso/Win10_1909_English_x64.iso' -var 'iso_checksum=01bf1eb643f7e50d0438f4f74fb91468d35cde2c82b07abc1390d47fc6a356be' windows_10.json
13 |
--------------------------------------------------------------------------------
/floppy/PinTo10.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffskinnerbox/Windows-10-Vagrant-Box/637c8f7607a3e0d9a7a42ef7b9910e2f69a80cf9/floppy/PinTo10.exe
--------------------------------------------------------------------------------
/floppy/ReadMe.txt:
--------------------------------------------------------------------------------
1 | : Release v1.2 - Stuart Pearson 16th Nov 2015
2 | :
3 | : Command line tool to pin and unpin exe / lnk files to the Windows 10 taskbar and start menu.
4 | :
5 | : PinTo10 is a command line tool to pin and unpin .exe or .lnk files to or from the Windows 10 taskbar and start menu.
6 | : With it you can pin or unpin up to 10 different shortcuts to either the taskbar or start menu in one run of the command.
7 | : It replaces functionality that Microsoft have removed from their Windows 10 scripting interface.
8 | :
9 | : The exe needs to be run with at least one pair of switches specified for each function to Pin / Unpin to Taskbar / Start Menu...
10 | :
11 | : To pin an application or shortcut to the taskbar (replace XX with 01-10)...
12 | : /PTFOLXX: Followed by the folder containing the file you want to pin.
13 | : /PTFILEXX: Followed by the name of the file you want to pin.
14 | :
15 | : To unpin an application or shortcut to the taskbar (replace XX with 01-10)...
16 | : /UTFOLXX: Followed by the folder containing the file you want to unpin.
17 | : /UTFILEXX: Followed by the name of the file you want to unpin.
18 |
19 | : To pin an application or shortcut to the start menu (replace XX with 01-10)...
20 | : /PSFOLXX: Followed by the folder containing the file you want to pin.
21 | : /PSFILEXX: Followed by the name of the file you want to pin.
22 |
23 | : To unpin an application or shortcut to the start menu (replace XX with 01-10)...
24 | : /USFOLXX: Followed by the folder containing the file you want to unpin.
25 | : /USFILEXX: Followed by the name of the file you want to unpin.
26 |
27 |
28 | : Example for pinning two shortcuts to the taskbar...
29 | PinTo10.exe /PTFOL01:'%USERPROFILE:%\Desktop' /PTFILE01:'Word 2016.lnk' /PTFOL02:'%USERPROFILE:%\Desktop' /PTFILE02:'Excel 2016.lnk'
30 |
31 | : Example for unpinning a file to the taskbar...
32 | PinTo10.exe /UTFOL01:'C\Windows' /UTFILE01:'notepad.exe'
33 |
34 | : Example for pinning a file to the start menu...
35 | PinTo10.exe /PSFOL01:'C\Windows' /PSFILE01:'notepad.exe'
36 |
37 | : Example for unpinning a file from the start menu...
38 | PinTo10.exe /USFOL01:'%USERPROFILE:%\Desktop' /USFILE01:'Word 2016.lnk'
--------------------------------------------------------------------------------
/floppy/WindowsPowershell.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeffskinnerbox/Windows-10-Vagrant-Box/637c8f7607a3e0d9a7a42ef7b9910e2f69a80cf9/floppy/WindowsPowershell.lnk
--------------------------------------------------------------------------------
/iso/README.md:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | # What Is This Directory For?
8 | You need to download or purchase your Windows ISO images
9 | and place them in this directory.
10 |
11 | ## Purchased Windows 10 Produce (i.e. Licensed)
12 | I purchased from [Microsoft Company Store][01]
13 | (Order # 1005131590, Order Date: 1/10/2020)
14 | a boxed version of the Windows 10 Operating System.
15 | It contains a USB thumb drive with a mountable filesystem.
16 | From this, I needed to create an ISO file to instantiate my Vagrant/VirtualBox VM.
17 |
18 | The Windows 10 product box USB thumb drive has a top level directory structure of:
19 |
20 | ```
21 | WINDOWS10/
22 | 'System Volume Information'/
23 | boot/
24 | efi/
25 | x64/
26 | x86/
27 | 83561421-11f5-4e09-8a59-933aks71366.ini
28 | autorun.inf
29 | bootmgr
30 | bootmgr.efi
31 | setup.exe*
32 | ```
33 |
34 | This top level directory `WINDOWS10` is bootable but
35 | it appears that the sub-directories `x64/` is my real target for creating my ISO file:
36 |
37 | ```
38 | WINDOWS10/
39 | x64/
40 | boot/
41 | efi/
42 | sources/
43 | support/
44 | autorun.inf
45 | bootmgr
46 | bootmgr.efi
47 | setup.exe*
48 | ```
49 |
50 | >**NOTE:** I concluded this via these articles:
51 | >
52 | >* [Difference between x64 and x86](http://net-informations.com/q/mis/x86.html)
53 | >* [What is x86 vs x64](https://forums.tomshardware.com/threads/what-is-x86-vs-x64.1220690/)
54 | >* [x86 vs x64 - Why is 32-bit called x86?](https://superuser.com/questions/179919/x86-vs-x64-why-is-32-bit-called-x86)
55 |
56 | ### Creating My ISO File
57 | With the purchased physical version of MS Windows 10 Pro,
58 | and now understanding the file structure on the USB drive,
59 | I needed to create my own [ISO 9660 filesystem image][04].
60 | To do this, I used [`genisoimage`][05] & some advice from [here][06].
61 | `genisoimage` is a command-line tool for creating ISO file.
62 |
63 | To create the ISO image for my MS Windows 10 ISO file destine for my VirtualBox vagrant box,
64 | I used the following command:
65 |
66 | ```bash
67 | # create iso image suitable for ms-windows from the usb drive filesystem
68 | genisoimage -no-emul-boot -b boot/etfsboot.com -boot-load-seg 0x07C0 -boot-load-size 8 -iso-level 2 -udf -joliet -R -D -N -V "VirtualBox-CD" -relaxed-filenames -o ./iso/windows-10-pro-020120.iso /media/jeff/WINDOWS10/x64
69 | ```
70 |
71 | Now lets checkout the newly create ISO file to make sure it is in good working order:
72 |
73 | ```bash
74 | # create a mount point and mount the iso file
75 | mkdir /media/jeff/VirtualBox-CD
76 | sudo mount -o loop ~/src/vagrant-machines/ms-windows/iso/windows-10-pro-020120.iso /media/jeff/VirtualBox-CD
77 |
78 | # verify the mounting
79 | df -H
80 | ls -l /media/jeff/VirtualBox-CD/
81 |
82 | # to unmount the iso file
83 | sudo umount /media/jeff/VirtualBox-CD/
84 | ```
85 |
86 | ### Office Professional and Visio
87 | I also purchased Office Professional 2019 and Visio Standard 2019
88 | and place the installation/setup files (they are not ISO files) in this directory.
89 | I didn't include these applications in the Vagrant base box
90 | but instead added them while building a box using Vagrant.
91 |
92 | So the contents of this directory inlcude the Windows Operating System
93 | and Microsoft application software as follows:
94 |
95 | ```
96 | # Created Windows 10 Disk Image (i.e. Licensed)
97 | windows-10-pro-020120.iso
98 |
99 | # Office Professional 2019 (i.e. Licensed)
100 | Setup.Def.en-US_Professional2019Retail_0d3ef3f9-ae67-4b97-a856-fff4d491ba2c_TX_PR_Platform_def_.exe
101 |
102 | # Visio Standard 2019 (i.e. Licensed)
103 | Setup.Def.en-US_VisioStd2019Retail_0738b055-a809-4718-9a19-bfc2ec63bb9f_TX_PR_Platform_def_.exe
104 | ```
105 |
106 |
107 | ----
108 |
109 |
110 | ## Alternatives
111 |
112 | ### Windows 10 Evaluation Copy (i.e. Unlicensed)
113 | As an alternative,
114 | you can download an evaluation copy of Windows 10 x64 Enterprise ([here][02]).
115 | The ISO file was loaded into `~/src/vagrant-machines/ms-windows/iso-files`.
116 | My file is:
117 |
118 | ```
119 | # Windows 10 Evaluation Copy (i.e. Unlicensed)
120 | 18363.418.191007-0143.19h2_release_svc_refresh_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso
121 | ```
122 |
123 | >**NOTE:** Ultimately, you're going to need a purchase a licensed version of Windows 10
124 | >but the evaluation copy gives you 90 days of free use.
125 |
126 | ### Windows Server Software (i.e. Licensed)
127 | You might want to consider the following sources for Windows Server software:
128 |
129 | * Windows Server 2008 R2 + SP1:
130 | * File Name: en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso
131 | * SHA1 Hash: D3FD7BF85EE1D5BDD72DE5B2C69A7B470733CD0A
132 | * Direct Download: http://msdn.microsoft.com/subscriptions/json/GetDownloadRequest?brand=MSDN&locale=en-us&fileId=44782&activexDisabled=true&akamaiDL=false
133 |
134 | * Windows Server 2008 R2 + SP1 (Volume License):
135 | * File Name: en_windows_server_2008_r2_with_sp1_vl_build_x64_dvd_617403.iso
136 | * SHA1 Hash: 7E7E9425041B3328CCF723A0855C2BC4F462EC57
137 | * Direct Download: http://msdn.microsoft.com/subscriptions/json/GetDownloadRequest?brand=MSDN&locale=en-us&fileId=44783&activexDisabled=true&akamaiDL=false
138 |
139 | * Windows Server 2012:
140 | * File Name: en_windows_server_2012_x64_dvd_915478.iso
141 | * SHA1 Hash: D09E752B1EE480BC7E93DFA7D5C3A9B8AAC477BA
142 | * Direct Download: http://msdn.microsoft.com/subscriptions/json/GetDownloadRequest?brand=MSDN&locale=en-us&fileId=50539&activexDisabled=true&akamaiDL=false
143 |
144 | * Windows Server 2012 (Volume License):
145 | * File Name: en_windows_server_2012_vl_x64_dvd_917758.iso
146 | * SHA1 Hash: 063BC26ED45C50D3745CCAD52DD7B3F3CE13F36D
147 | * Direct Download: http://msdn.microsoft.com/subscriptions/json/GetDownloadRequest?brand=MSDN&locale=en-us&fileId=50573&activexDisabled=true&akamaiDL=false
148 |
149 |
150 |
151 | [01]:https://store.ecompanystore.com/microsoft/Shop/#/
152 | [02]:https://www.microsoft.com/en-us/software-download/windows10ISO
153 | [04]:https://en.wikipedia.org/wiki/ISO_9660
154 | [05]:http://www.tuxarena.com/static/tut_iso_cli.php
155 | [06]:https://thomas-cokelaer.info/blog/2011/05/how-to-create-an-iso-image-from-a-folder-linux/
156 |
157 |
--------------------------------------------------------------------------------
/scripts/.gitignore:
--------------------------------------------------------------------------------
1 | *.exe
2 | *.msi
3 | *.msu
--------------------------------------------------------------------------------
/scripts/chef.bat:
--------------------------------------------------------------------------------
1 | if not exist "C:\Windows\Temp\chef.msi" (
2 | powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://www.getchef.com/chef/install.msi', 'C:\Windows\Temp\chef.msi')" NUL
7 | %windir%\microsoft.net\framework\v4.0.30319\ngen.exe executequeueditems > NUL
8 |
9 | exit 0
10 |
11 | :64BIT
12 | %windir%\microsoft.net\framework\v4.0.30319\ngen.exe update /force /queue > NUL
13 | %windir%\microsoft.net\framework64\v4.0.30319\ngen.exe update /force /queue > NUL
14 | %windir%\microsoft.net\framework\v4.0.30319\ngen.exe executequeueditems > NUL
15 | %windir%\microsoft.net\framework64\v4.0.30319\ngen.exe executequeueditems > NUL
16 |
17 | exit 0
18 |
--------------------------------------------------------------------------------
/scripts/create-domain.ps1:
--------------------------------------------------------------------------------
1 | if ((gwmi win32_computersystem).partofdomain -eq $false) {
2 |
3 | Write-Host 'Creating domain controller'
4 | # Disable password complexity policy
5 | secedit /export /cfg C:\secpol.cfg
6 | (gc C:\secpol.cfg).replace("PasswordComplexity = 1", "PasswordComplexity = 0") | Out-File C:\secpol.cfg
7 | secedit /configure /db C:\Windows\security\local.sdb /cfg C:\secpol.cfg /areas SECURITYPOLICY
8 | rm -force C:\secpol.cfg -confirm:$false
9 |
10 | # Set administrator password
11 | $computerName = $env:COMPUTERNAME
12 | $adminPassword = "vagrant"
13 | $adminUser = [ADSI] "WinNT://$computerName/Administrator,User"
14 | $adminUser.SetPassword($adminPassword)
15 |
16 | $PlainPassword = "vagrant" # "P@ssw0rd"
17 | $SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
18 |
19 | # Windows Server 2012 R2
20 | Install-WindowsFeature AD-domain-services
21 | Import-Module ADDSDeployment
22 | Install-ADDSForest `
23 | -SafeModeAdministratorPassword $SecurePassword `
24 | -CreateDnsDelegation:$false `
25 | -DatabasePath "C:\Windows\NTDS" `
26 | -DomainMode "Win2012" `
27 | -DomainName "windomain.local" `
28 | -DomainNetbiosName "WINDOMAIN" `
29 | -ForestMode "Win2012" `
30 | -InstallDns:$true `
31 | -LogPath "C:\Windows\NTDS" `
32 | -NoRebootOnCompletion:$true `
33 | -SysvolPath "C:\Windows\SYSVOL" `
34 | -Force:$true
35 |
36 | $newDNSServers = "8.8.8.8", "4.4.4.4"
37 | $adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPAddress -eq "10.0.2.15"}
38 | $adapters | ForEach-Object {$_.SetDNSServerSearchOrder($newDNSServers)}
39 | }
40 |
--------------------------------------------------------------------------------
/scripts/debloat-windows.ps1:
--------------------------------------------------------------------------------
1 | if ($env:PACKER_BUILDER_TYPE -And $($env:PACKER_BUILDER_TYPE).startsWith("hyperv")) {
2 | Write-Host Skip debloat steps in Hyper-V build.
3 | } else {
4 | Write-Host Downloading debloat zip
5 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
6 | $url="https://github.com/StefanScherer/Debloat-Windows-10/archive/master.zip"
7 | (New-Object System.Net.WebClient).DownloadFile($url, "$env:TEMP\debloat.zip")
8 | Expand-Archive -Path $env:TEMP\debloat.zip -DestinationPath $env:TEMP -Force
9 |
10 | #Write-Host Disable scheduled tasks
11 | #. $env:TEMP\Debloat-Windows-10-master\utils\disable-scheduled-tasks.ps1
12 | #Write-Host Block telemetry
13 | #. $env:TEMP\Debloat-Windows-10-master\scripts\block-telemetry.ps1
14 | #Write-Host Disable services
15 | #. $env:TEMP\Debloat-Windows-10-master\scripts\disable-services.ps1
16 | Write-host Disable Windows Defender
17 | if ($(gp "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ProductName.StartsWith("Windows 10")) {
18 | . $env:TEMP\Debloat-Windows-10-master\scripts\disable-windows-defender.ps1
19 | } else {
20 | Uninstall-WindowsFeature Windows-Defender-Features
21 | }
22 | Write-host Optimize Windows Update
23 | . $env:TEMP\Debloat-Windows-10-master\scripts\optimize-windows-update.ps1
24 | #Write-host Disable Windows Update
25 | #Set-Service wuauserv -StartupType Disabled
26 | #Write-Host Remove OneDrive
27 | #. $env:TEMP\Debloat-Windows-10-master\scripts\remove-onedrive.ps1
28 |
29 | rm $env:TEMP\debloat.zip
30 | rm -recurse $env:TEMP\Debloat-Windows-10-master
31 | }
32 |
--------------------------------------------------------------------------------
/scripts/dis-updates.bat:
--------------------------------------------------------------------------------
1 | rem http://www.windows-commandline.com/disable-automatic-updates-command-line/
2 | reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f
3 |
4 | rem remove optional WSUS server settings
5 | reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /f
6 |
7 | rem even harder, disable windows update service
8 | rem sc config wuauserv start= disabled
9 | rem net stop wuauserv
10 | set logfile=C:\Windows\Temp\win-updates.log
11 |
12 | if exist %logfile% (
13 | echo Show Windows Updates log file %logfile%
14 | dir %logfile%
15 | type %logfile%
16 | rem output of type command is not fully shown in packer/ssh session, so try PowerShell
17 | rem but it will hang if log file is about 22 KByte
18 | rem powershell -command "Get-Content %logfile%"
19 | echo End of Windows Updates log file %logfile%
20 | )
21 |
--------------------------------------------------------------------------------
/scripts/dis-updates.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Disables automatic windows updates
4 | .DESCRIPTION
5 | Disables checking for and applying Windows Updates (does not prevent updates from being applied manually or being pushed down)
6 | Run on the machine that updates need disabling on.
7 | .PARAMETER
8 | None
9 | .EXAMPLE
10 | ./Disable-WindowsUpdates.ps1
11 | #>
12 | $RunningAsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
13 | if ($RunningAsAdmin)
14 | {
15 |
16 | $Updates = (New-Object -ComObject "Microsoft.Update.AutoUpdate").Settings
17 |
18 | if ($Updates.ReadOnly -eq $True) { Write-Error "Cannot update Windows Update settings due to GPO restrictions." }
19 |
20 | else {
21 | $Updates.NotificationLevel = 1 #Disabled
22 | $Updates.Save()
23 | $Updates.Refresh()
24 | Write-Output "Automatic Windows Updates disabled."
25 | }
26 | }
27 |
28 | else
29 | { Write-Warning "Must be executed in Administrator level shell."
30 | Write-Warning "Script Cancelled!" }
31 |
--------------------------------------------------------------------------------
/scripts/disable-auto-logon.bat:
--------------------------------------------------------------------------------
1 | reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /d 0 /f
--------------------------------------------------------------------------------
/scripts/disable-screensaver.ps1:
--------------------------------------------------------------------------------
1 | Write-Host "Disabling Screensaver"
2 | Set-ItemProperty "HKCU:\Control Panel\Desktop" -Name ScreenSaveActive -Value 0 -Type DWord
3 | & powercfg -x -monitor-timeout-ac 0
4 | & powercfg -x -monitor-timeout-dc 0
5 |
--------------------------------------------------------------------------------
/scripts/disable-tasks.bat:
--------------------------------------------------------------------------------
1 | schtasks /End /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"
2 | schtasks /Change /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /DISABLE
3 |
--------------------------------------------------------------------------------
/scripts/disable-winrm.ps1:
--------------------------------------------------------------------------------
1 | netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=block
2 | netsh advfirewall firewall set rule group="Windows Remote Management" new enable=yes
3 | $winrmService = Get-Service -Name WinRM
4 | if ($winrmService.Status -eq "Running"){
5 | Disable-PSRemoting -Force
6 | }
7 | Stop-Service winrm
8 | Set-Service -Name winrm -StartupType Disabled
9 |
--------------------------------------------------------------------------------
/scripts/docker/10/install-containers-feature.ps1:
--------------------------------------------------------------------------------
1 | # https://msdn.microsoft.com/de-de/virtualization/windowscontainers/quick_start/quick_start_windows_10
2 | Write-Host "Install Containers feature"
3 | Enable-WindowsOptionalFeature -Online -FeatureName containers -All -NoRestart
4 | Write-Host "Install Hyper-V feature"
5 | Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
6 | sc.exe config winrm start= delayed-auto
7 |
--------------------------------------------------------------------------------
/scripts/docker/2016/install-containers-feature.ps1:
--------------------------------------------------------------------------------
1 | Write-Host "Install Containers feature"
2 | Install-WindowsFeature -Name Containers
3 |
4 | if ((GWMI Win32_Processor).VirtualizationFirmwareEnabled[0] -and (GWMI Win32_Processor).SecondLevelAddressTranslationExtensions[0]) {
5 | Write-Host "Install Hyper-V feature"
6 | Install-WindowsFeature -Name Hyper-V -IncludeManagementTools
7 | } else {
8 | Write-Host "Skipping installation of Hyper-V feature"
9 | }
10 |
--------------------------------------------------------------------------------
/scripts/docker/add-docker-group.ps1:
--------------------------------------------------------------------------------
1 | Write-Host Creating group docker
2 | net localgroup docker /add
3 | $username = $env:USERNAME
4 | Write-Host Adding user $username to group docker
5 | net localgroup docker $username /add
6 |
--------------------------------------------------------------------------------
/scripts/docker/chocolatey-and-tools.ps1:
--------------------------------------------------------------------------------
1 |
2 | Write-Output 'Do not open Server Manager at logon'
3 | New-ItemProperty -Path HKCU:\Software\Microsoft\ServerManager -Name DoNotOpenServerManagerAtLogon -PropertyType DWORD -Value "1" -Force
4 |
5 | Write-Output 'Install bginfo'
6 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
7 |
8 | if (!(Test-Path 'c:\Program Files\sysinternals')) {
9 | New-Item -Path 'c:\Program Files\sysinternals' -type directory -Force -ErrorAction SilentlyContinue
10 | }
11 | if (!(Test-Path 'c:\Program Files\sysinternals\bginfo.exe')) {
12 | (New-Object Net.WebClient).DownloadFile('https://live.sysinternals.com/bginfo.exe', 'c:\Program Files\sysinternals\bginfo.exe')
13 | }
14 | if (!(Test-Path 'c:\Program Files\sysinternals\bginfo.bgi')) {
15 | (New-Object Net.WebClient).DownloadFile('https://github.com/StefanScherer/windows-docker-workshop/raw/master/prepare-vms/azure/packer/bginfo.bgi', 'c:\Program Files\sysinternals\bginfo.bgi')
16 | }
17 | if (!(Test-Path 'c:\Program Files\sysinternals\background.jpg')) {
18 | (New-Object Net.WebClient).DownloadFile('https://github.com/StefanScherer/windows-docker-workshop/raw/master/prepare-vms/azure/packer/background.jpg', 'c:\Program Files\sysinternals\background.jpg')
19 | }
20 | $vbsScript = @'
21 | WScript.Sleep 2000
22 | Dim objShell
23 | Set objShell = WScript.CreateObject( "WScript.Shell" )
24 | objShell.Run("""c:\Program Files\sysinternals\bginfo.exe"" /accepteula ""c:\Program Files\sysinternals\bginfo.bgi"" /silent /timer:0")
25 | '@
26 | $vbsScript | Out-File 'c:\Program Files\sysinternals\bginfo.vbs'
27 | Set-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run -Name bginfo -Value 'wscript "c:\Program Files\sysinternals\bginfo.vbs"'
28 | wscript "c:\Program Files\sysinternals\bginfo.vbs"
29 |
30 | Write-Output 'Install Chocolatey'
31 | Invoke-WebRequest 'https://chocolatey.org/install.ps1' -UseBasicParsing | Invoke-Expression
32 |
33 | Write-Output 'Install editors'
34 | choco install -y visualstudiocode
35 |
36 | Write-Output 'Install Git'
37 | choco install -y git
38 |
39 | Write-Output 'Install browsers'
40 | choco install -y googlechrome
41 | choco install -y firefox
42 |
43 | Write-Output 'Install Docker Compose'
44 | choco install -y docker-compose
45 |
--------------------------------------------------------------------------------
/scripts/docker/disable-windows-defender.ps1:
--------------------------------------------------------------------------------
1 | Set-MpPreference -DisableRealtimeMonitoring $true
--------------------------------------------------------------------------------
/scripts/docker/docker-pull.ps1:
--------------------------------------------------------------------------------
1 | $images = ""
2 | if (Test-Path env:docker_images) {
3 | $images = $env:docker_images.split()
4 | }
5 |
6 | function DockerPull {
7 | Param ([string]$image)
8 |
9 | if ($image -eq "") {
10 | return
11 | }
12 |
13 | Write-Host Installing $image ...
14 | $j = Start-Job -ScriptBlock { docker pull $args[0] } -ArgumentList "$image"
15 | while ( $j.JobStateInfo.state -ne "Completed" -And $j.JobStateInfo.state -ne "Failed" ) {
16 | Write-Host $j.JobStateInfo.state
17 | Start-Sleep 30
18 | }
19 |
20 | $results = Receive-Job -Job $j
21 | $results
22 | }
23 |
24 | function DockerRun {
25 | Param ([string]$image)
26 |
27 | if ($image -eq "") {
28 | return
29 | }
30 |
31 | Write-Host Run first container from $image ...
32 | docker run --rm $image cmd
33 | }
34 |
35 | $images | foreach {
36 | DockerPull $_
37 | }
38 | $images | foreach {
39 | DockerPull $_
40 | }
41 |
42 | $images | foreach {
43 | DockerRun $_
44 | }
45 |
--------------------------------------------------------------------------------
/scripts/docker/enable-winrm.ps1:
--------------------------------------------------------------------------------
1 | Enable-PSRemoting -Force
2 | winrm quickconfig -q
3 | winrm quickconfig -transport:http
4 | winrm set winrm/config '@{MaxTimeoutms="1800000"}'
5 | winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="800"}'
6 | winrm set winrm/config/service '@{AllowUnencrypted="true"}'
7 | winrm set winrm/config/service/auth '@{Basic="true"}'
8 | winrm set winrm/config/client/auth '@{Basic="true"}'
9 | winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}'
10 |
11 | if (Test-Path A:\install-containers-feature.ps1) {
12 | . A:\install-containers-feature.ps1
13 | }
14 |
15 | Stop-Service winrm
16 | . sc.exe config winrm start= delayed-auto
17 |
18 | netsh advfirewall firewall set rule group="Windows Remote Administration" new enable=yes
19 | netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow
20 |
21 | Restart-Computer
22 |
--------------------------------------------------------------------------------
/scripts/docker/install-docker.ps1:
--------------------------------------------------------------------------------
1 | # use docker_provider: "ee", "ce", "master" or ""
2 | $docker_provider = "ee"
3 | $docker_version = "18.09.9"
4 | if (Test-Path env:docker_provider) {
5 | $docker_provider = $env:docker_provider
6 | }
7 | if (Test-Path env:docker_version) {
8 | $docker_version = $env:docker_version
9 | }
10 |
11 | $ProgressPreference = 'SilentlyContinue'
12 | if ($docker_provider -eq "ce") {
13 | $zip_url = $("https://download.docker.com/win/static/edge/x86_64/docker-{0}-ce.zip" -f $docker_version)
14 | } elseif ($docker_provider -eq "ee") {
15 | $folder = $docker_version -replace "\.\d+$", ""
16 | $zip_url = $("https://download.docker.com/components/engine/windows-server/{0}/docker-{1}.zip" -f $folder, $docker_version)
17 | } elseif ($docker_provider -eq "master") {
18 | $docker_version = "master"
19 | $zip_url = "https://master.dockerproject.com/windows/x86_64/docker.zip"
20 | }
21 |
22 | if ($zip_url) {
23 | Set-ExecutionPolicy Bypass -scope Process
24 | New-Item -Type Directory -Path "$($env:ProgramFiles)\docker"
25 | Write-Output "Downloading docker $docker_version ..."
26 | wget -outfile $env:TEMP\docker.zip $zip_url
27 | Expand-Archive -Path $env:TEMP\docker.zip -DestinationPath $env:TEMP -Force
28 | copy $env:TEMP\docker\*.* $env:ProgramFiles\docker
29 | Remove-Item $env:TEMP\docker.zip
30 | Remove-Item -Recurse $env:TEMP\docker
31 | [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$($env:ProgramFiles)\docker", [EnvironmentVariableTarget]::Machine)
32 | $env:Path = $env:Path + ";$($env:ProgramFiles)\docker"
33 | Write-Output "Registering docker service ..."
34 | . dockerd --register-service
35 | } else {
36 | Write-Output "Install-PackageProvider ..."
37 | Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
38 | Write-Output "Install-Module $docker_provider ..."
39 | Install-Module -Name $docker_provider -Repository PSGallery -Force
40 | Write-Output "Install-Package docker version $docker_version ..."
41 | Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
42 | $ErrorActionStop = 'SilentlyContinue'
43 | Install-Package -Name docker -ProviderName $docker_provider -RequiredVersion $docker_version -Force
44 | Set-PSRepository -InstallationPolicy Untrusted -Name PSGallery
45 | }
46 |
47 | $ErrorActionPreference = 'Stop'
48 | Write-Output "Starting docker ..."
49 | Start-Service docker
50 |
--------------------------------------------------------------------------------
/scripts/docker/open-docker-insecure-port.ps1:
--------------------------------------------------------------------------------
1 | Write-Host "WARNING: DO NOT USE DOCKER IN PRODUCTION WITHOUT TLS"
2 | Write-Host "Opening Docker insecure port 2375"
3 |
4 | if (!(Get-NetFirewallRule | where {$_.Name -eq "Dockerinsecure2375"})) {
5 | New-NetFirewallRule -Name "Dockerinsecure2375" -DisplayName "Docker insecure on TCP/2375" -Protocol tcp -LocalPort 2375 -Action Allow -Enabled True
6 | }
7 |
--------------------------------------------------------------------------------
/scripts/docker/open-docker-swarm-ports.ps1:
--------------------------------------------------------------------------------
1 | Write-Host "Opening Docker swarm mode ports"
2 |
3 | if (!(Get-NetFirewallRule | where {$_.Name -eq "Dockerswarm2377"})) {
4 | New-NetFirewallRule -Name "Dockerswarm2377" -DisplayName "Docker Swarm Mode Management TCP/2377" -Protocol tcp -LocalPort 2377 -Action Allow -Enabled True
5 | }
6 | if (!(Get-NetFirewallRule | where {$_.Name -eq "Dockerswarm7946"})) {
7 | New-NetFirewallRule -Name "Dockerswarm7946" -DisplayName "Docker Swarm Mode Node Communication TCP/7946" -Protocol tcp -LocalPort 7946 -Action Allow -Enabled True
8 | }
9 | if (!(Get-NetFirewallRule | where {$_.Name -eq "Dockerswarm7946udp"})) {
10 | New-NetFirewallRule -Name "Dockerswarm7946udp" -DisplayName "Docker Swarm Mode Node Communication UDP/7946" -Protocol udp -LocalPort 7946 -Action Allow -Enabled True
11 | }
12 | if (!(Get-NetFirewallRule | where {$_.Name -eq "Dockerswarm4789"})) {
13 | New-NetFirewallRule -Name "Dockerswarm4789" -DisplayName "Docker Swarm Overlay Network Traffic TCP/4789" -Protocol tcp -LocalPort 4789 -Action Allow -Enabled True
14 | }
15 |
--------------------------------------------------------------------------------
/scripts/docker/remove-docker-key-json.ps1:
--------------------------------------------------------------------------------
1 | # Do not restart Docker as it creates the key.json with an unique ID
2 | # This should not exist in the Vagrant basebox so you can spin up
3 | # multiple Vagrant boxes for a Docker swarm etc.
4 |
5 | Write-Host "Stopping Docker"
6 | Stop-Service docker
7 |
8 | Write-Host "Removing key.json to recreate key.json on first vagrant up"
9 | rm C:\ProgramData\docker\config\key.json
10 |
--------------------------------------------------------------------------------
/scripts/docker/set-winrm-automatic.ps1:
--------------------------------------------------------------------------------
1 | . sc.exe config winrm start= auto
2 |
--------------------------------------------------------------------------------
/scripts/docker/set-winrm-delayed-automatic.ps1:
--------------------------------------------------------------------------------
1 | . sc.exe config winrm start= delayed-auto
2 |
--------------------------------------------------------------------------------
/scripts/enable-rdp.bat:
--------------------------------------------------------------------------------
1 | netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389
2 | reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
3 |
--------------------------------------------------------------------------------
/scripts/enable-remote-desktop.bat:
--------------------------------------------------------------------------------
1 | rem from http://networkerslog.blogspot.de/2013/09/how-to-enable-remote-desktop-remotely.html
2 |
3 | rem 1) Enable Remote Desktop
4 | rem set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -Value 0
5 | reg add "HKLM\System\CurrentControlSet\Control\Terminal Server" /v "fDenyTSConnections" /t REG_DWORD /d 0 /f
6 |
7 | rem 2) Allow incoming RDP on firewall
8 | rem Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
9 | netsh advfirewall firewall set rule group="Remote Desktop" new enable=yes
10 |
11 | rem 3) Enable secure RDP authentication
12 | rem set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 0
13 | reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "UserAuthentication" /t REG_DWORD /d 0 /f
14 |
15 |
--------------------------------------------------------------------------------
/scripts/enable-uac.bat:
--------------------------------------------------------------------------------
1 | reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 1 /f
2 |
--------------------------------------------------------------------------------
/scripts/enable-winrm.bat:
--------------------------------------------------------------------------------
1 | rem Enable-NetFirewallRule for WinRM
2 | netsh advfirewall firewall add rule name="Port 5985" dir=in action=allow protocol=TCP localport=5985
3 | sc.exe config winrm start= auto
4 |
--------------------------------------------------------------------------------
/scripts/enable-winrm.ps1:
--------------------------------------------------------------------------------
1 | $NetworkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
2 | $Connections = $NetworkListManager.GetNetworkConnections()
3 | $Connections | ForEach-Object { $_.GetNetwork().SetCategory(1) }
4 |
5 | Enable-PSRemoting -Force
6 | winrm quickconfig -q
7 | winrm quickconfig -transport:http
8 | winrm set winrm/config '@{MaxTimeoutms="1800000"}'
9 | winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="800"}'
10 | winrm set winrm/config/service '@{AllowUnencrypted="true"}'
11 | winrm set winrm/config/service/auth '@{Basic="true"}'
12 | winrm set winrm/config/client/auth '@{Basic="true"}'
13 | winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}'
14 | netsh advfirewall firewall set rule group="Windows Remote Administration" new enable=yes
15 | netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow
16 | Set-Service winrm -startuptype "auto"
17 | Restart-Service winrm
18 |
--------------------------------------------------------------------------------
/scripts/fixnetwork.ps1:
--------------------------------------------------------------------------------
1 | # You cannot enable Windows PowerShell Remoting on network connections that are set to Public
2 | # Spin through all the network locations and if they are set to Public, set them to Private
3 | # using the INetwork interface:
4 | # http://msdn.microsoft.com/en-us/library/windows/desktop/aa370750(v=vs.85).aspx
5 | # For more info, see:
6 | # http://blogs.msdn.com/b/powershell/archive/2009/04/03/setting-network-location-to-private.aspx
7 |
8 | # Network location feature was only introduced in Windows Vista - no need to bother with this
9 | # if the operating system is older than Vista
10 | if([environment]::OSVersion.version.Major -lt 6) { return }
11 |
12 | # You cannot change the network location if you are joined to a domain, so abort
13 | if(1,3,4,5 -contains (Get-WmiObject win32_computersystem).DomainRole) { return }
14 |
15 | # Get network connections
16 | $networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
17 | $connections = $networkListManager.GetNetworkConnections()
18 |
19 | $connections |foreach {
20 | Write-Host $_.GetNetwork().GetName()"category was previously set to"$_.GetNetwork().GetCategory()
21 | $_.GetNetwork().SetCategory(1)
22 | Write-Host $_.GetNetwork().GetName()"changed to category"$_.GetNetwork().GetCategory()
23 | }
24 |
--------------------------------------------------------------------------------
/scripts/hotfix-KB2552055.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | :: Windows 7 / Windows 2008 R2 require KB2552055 hotfix
3 | :: This fixes a problem with wrong exitcode 0 instead of custom exitcode in PowerShell 2.0
4 | setlocal
5 | if defined ProgramFiles(x86) (
6 | set link=https://hotfixv4.microsoft.com/Windows%%207/Windows%%20Server2008%%20R2%%20SP1/sp2/Fix373932/7600/free/438167_intl_x64_zip.exe
7 | set msufilename=%TEMP%\Windows6.1-KB2552055-x64.msu
8 | ) else (
9 | set link=https://hotfixv4.microsoft.com/Windows%%207/Windows%%20Server2008%%20R2%%20SP1/sp2/Fix373932/7600/free/438164_intl_i386_zip.exe
10 | set msufilename=%TEMP%\Windows6.1-KB2552055-x86.msu
11 | )
12 | set zipfilename=%TEMP%\KB2552055.zip
13 |
14 | echo Downloading Hotfix 2552055
15 | powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%link%', '%zipfilename%')" A:\temp.vbs
8 | echo Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"") >> A:\temp.vbs
9 |
10 | cscript A:\temp.vbs
11 |
12 | net start wuauserv
13 |
--------------------------------------------------------------------------------
/scripts/openssh.ps1:
--------------------------------------------------------------------------------
1 | param (
2 | [switch]$AutoStart = $false
3 | )
4 |
5 | Write-Output "AutoStart: $AutoStart"
6 | $is_64bit = [IntPtr]::size -eq 8
7 |
8 | # setup openssh
9 | $ssh_download_url = "https://www.mls-software.com/files/setupssh-7.1p1-1.exe"
10 |
11 | if (!(Test-Path "C:\Program Files\OpenSSH\bin\ssh.exe")) {
12 | Write-Output "Downloading $ssh_download_url"
13 | (New-Object System.Net.WebClient).DownloadFile($ssh_download_url, "C:\Windows\Temp\openssh.exe")
14 |
15 | # initially set the port to 2222 so that there is not a race
16 | # condition in which packer connects to SSH before we can disable the service
17 | Start-Process "C:\Windows\Temp\openssh.exe" "/S /port=2222 /privsep=1 /password=D@rj33l1ng" -NoNewWindow -Wait
18 | }
19 |
20 | Stop-Service "OpenSSHd" -Force
21 |
22 | # ensure vagrant can log in
23 | Write-Output "Setting vagrant user file permissions"
24 | New-Item -ItemType Directory -Force -Path "C:\Users\vagrant\.ssh"
25 | C:\Windows\System32\icacls.exe "C:\Users\vagrant" /grant "vagrant:(OI)(CI)F"
26 | C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\bin" /grant "vagrant:(OI)RX"
27 | C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\usr\sbin" /grant "vagrant:(OI)RX"
28 |
29 | Write-Output "Setting SSH home directories"
30 | (Get-Content "C:\Program Files\OpenSSH\etc\passwd") |
31 | Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } |
32 | Set-Content 'C:\Program Files\OpenSSH\etc\passwd'
33 |
34 | # disabled for vcloud to make vagrant-serverspec work
35 | # Set shell to /bin/sh to return exit status
36 | # $passwd_file = Get-Content 'C:\Program Files\OpenSSH\etc\passwd'
37 | # $passwd_file = $passwd_file -replace '/bin/bash', '/bin/sh'
38 | # Set-Content 'C:\Program Files\OpenSSH\etc\passwd' $passwd_file
39 |
40 | # fix opensshd to not be strict
41 | Write-Output "Setting OpenSSH to be non-strict"
42 | $sshd_config = Get-Content "C:\Program Files\OpenSSH\etc\sshd_config"
43 | $sshd_config = $sshd_config -replace 'StrictModes yes', 'StrictModes no'
44 | $sshd_config = $sshd_config -replace '#PubkeyAuthentication yes', 'PubkeyAuthentication yes'
45 | $sshd_config = $sshd_config -replace '#PermitUserEnvironment no', 'PermitUserEnvironment yes'
46 | # disable the use of DNS to speed up the time it takes to establish a connection
47 | $sshd_config = $sshd_config -replace '#UseDNS yes', 'UseDNS no'
48 | # disable the login banner
49 | $sshd_config = $sshd_config -replace 'Banner /etc/banner.txt', '#Banner /etc/banner.txt'
50 | # next time OpenSSH starts have it listen on th eproper port
51 | $sshd_config = $sshd_config -replace 'Port 2222', "Port 22"
52 | Set-Content "C:\Program Files\OpenSSH\etc\sshd_config" $sshd_config
53 |
54 | Write-Output "Removing ed25519 key as Vagrant net-ssh 2.9.1 does not support it"
55 | Remove-Item -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\etc\ssh_host_ed25519_key"
56 | Remove-Item -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\etc\ssh_host_ed25519_key.pub"
57 |
58 | # use c:\Windows\Temp as /tmp location
59 | Write-Output "Setting temp directory location"
60 | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\tmp"
61 | C:\Program` Files\OpenSSH\bin\junction.exe /accepteula "C:\Program Files\OpenSSH\tmp" "C:\Windows\Temp"
62 | C:\Windows\System32\icacls.exe "C:\Windows\Temp" /grant "vagrant:(OI)(CI)F"
63 |
64 | # add 64 bit environment variables missing from SSH
65 | Write-Output "Setting SSH environment"
66 | $sshenv = "TEMP=C:\Windows\Temp"
67 | if ($is_64bit) {
68 | $env_vars = "ProgramFiles(x86)=C:\Program Files (x86)", `
69 | "ProgramW6432=C:\Program Files", `
70 | "CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files", `
71 | "CommonProgramW6432=C:\Program Files\Common Files"
72 | $sshenv = $sshenv + "`r`n" + ($env_vars -join "`r`n")
73 | }
74 | Set-Content C:\Users\vagrant\.ssh\environment $sshenv
75 |
76 | # record the path for provisioners (without the newline)
77 | Write-Output "Recording PATH for provisioners"
78 | Set-Content C:\Windows\Temp\PATH ([byte[]][char[]] $env:PATH) -Encoding Byte
79 |
80 | # configure firewall
81 | Write-Output "Configuring firewall"
82 | netsh advfirewall firewall add rule name="SSHD" dir=in action=allow service=OpenSSHd enable=yes
83 | netsh advfirewall firewall add rule name="SSHD" dir=in action=allow program="C:\Program Files\OpenSSH\usr\sbin\sshd.exe" enable=yes
84 | netsh advfirewall firewall add rule name="ssh" dir=in action=allow protocol=TCP localport=22
85 |
86 | if ($AutoStart -eq $true) {
87 | Start-Service "OpenSSHd"
88 | }
89 |
--------------------------------------------------------------------------------
/scripts/pin-powershell.bat:
--------------------------------------------------------------------------------
1 | rem https://connect.microsoft.com/PowerShell/feedback/details/1609288/pin-to-taskbar-no-longer-working-in-windows-10
2 | copy "A:\WindowsPowerShell.lnk" "%TEMP%\Windows PowerShell.lnk"
3 | A:\PinTo10.exe /PTFOL01:'%TEMP%' /PTFILE01:'Windows PowerShell.lnk'
4 | exit /b 0
5 |
--------------------------------------------------------------------------------
/scripts/prepare-for-upload-vhd-image.ps1:
--------------------------------------------------------------------------------
1 | # https://docs.microsoft.com/de-de/azure/virtual-machines/windows/prepare-for-upload-vhd-image
2 | netsh winhttp reset proxy
3 | "san policy=onlineall" | Out-File -Encoding Ascii $env:TEMP\diskpart.txt
4 | & diskpart /s $env:TEMP\diskpart.txt
5 |
6 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation' -name "RealTimeIsUniversal" 1 -Type DWord
7 | Set-Service -Name w32time -StartupType Automatic
8 |
9 | powercfg /setactive SCHEME_MIN
10 |
11 | Set-Service -Name bfe -StartupType Automatic
12 | Set-Service -Name dhcp -StartupType Automatic
13 | Set-Service -Name dnscache -StartupType Automatic
14 | Set-Service -Name IKEEXT -StartupType Automatic
15 | Set-Service -Name iphlpsvc -StartupType Automatic
16 | Set-Service -Name netlogon -StartupType Manual
17 | Set-Service -Name netman -StartupType Manual
18 | Set-Service -Name nsi -StartupType Automatic
19 | Set-Service -Name termService -StartupType Manual
20 | Set-Service -Name MpsSvc -StartupType Automatic
21 | Set-Service -Name RemoteRegistry -StartupType Automatic
22 |
23 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -Value 0 -Type DWord
24 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -name "fDenyTSConnections" -Value 0 -Type DWord
25 |
26 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Winstations\RDP-Tcp' -name "PortNumber" 3389 -Type DWord
27 |
28 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Winstations\RDP-Tcp' -name "LanAdapter" 0 -Type DWord
29 |
30 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" 1 -Type DWord
31 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "SecurityLayer" 1 -Type DWord
32 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "fAllowSecProtocolNegotiation" 1 -Type DWord
33 |
34 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -name "KeepAliveEnable" 1 -Type DWord
35 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -name "KeepAliveInterval" 1 -Type DWord
36 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Winstations\RDP-Tcp' -name "KeepAliveTimeout" 1 -Type DWord
37 |
38 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -name "fDisableAutoReconnect" 0 -Type DWord
39 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Winstations\RDP-Tcp' -name "fInheritReconnectSame" 1 -Type DWord
40 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Winstations\RDP-Tcp' -name "fReconnectSame" 0 -Type DWord
41 |
42 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Winstations\RDP-Tcp' -name "MaxInstanceCount" 4294967295 -Type DWord
43 |
44 | Remove-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "SSLCertificateSHA1Hash"
45 |
46 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\services\SharedAccess\Parameters\FirewallPolicy\DomainProfile' -name "EnableFirewall" -Value 1 -Type DWord
47 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\services\SharedAccess\Parameters\FirewallPolicy\PublicProfile' -name "EnableFirewall" -Value 1 -Type DWord
48 | Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\services\SharedAccess\Parameters\FirewallPolicy\Standardprofile' -name "EnableFirewall" -Value 1 -Type DWord
49 |
50 | Enable-PSRemoting -force
51 | netsh advfirewall firewall set rule dir=in name="Windows Remote Management (HTTP-In)" new enable=yes
52 | netsh advfirewall firewall set rule dir=in name="Windows Remote Management (HTTP-In)" new enable=yes
53 |
54 | netsh advfirewall firewall set rule group="Remote Desktop" new enable=yes
55 |
56 | netsh advfirewall firewall set rule dir=in name="File and Printer Sharing (Echo Request - ICMPv4-In)" new enable=yes
57 |
58 |
59 | bcdedit /set '{bootmgr}' integrityservices enable
60 | bcdedit /set '{default}' device partition=C:
61 | bcdedit /set '{default}' integrityservices enable
62 | bcdedit /set '{default}' recoveryenabled Off
63 | bcdedit /set '{default}' osdevice partition=C:
64 | bcdedit /set '{default}' bootstatuspolicy IgnoreAllFailures
65 |
66 | #Enable Serial Console Feature
67 | bcdedit /set '{bootmgr}' displaybootmenu yes
68 | bcdedit /set '{bootmgr}' timeout 10
69 | bcdedit /set '{bootmgr}' bootems yes
70 | bcdedit /ems '{current}' ON
71 | bcdedit /emssettings EMSPORT:1 EMSBAUDRATE:115200
72 |
73 | #Setup the Guest OS to collect a kernel dump on an OS crash event
74 | REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\CrashControl" /v DumpFile /t REG_EXPAND_SZ /d "%SystemRoot%\MEMORY.DMP" /f
75 | REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\CrashControl" /v CrashDumpEnabled /t REG_DWORD /d 2 /f
76 | REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\CrashControl" /v NMICrashDump /t REG_DWORD /d 1 /f
77 |
78 | #Setup the Guest OS to collect user mode dumps on a service crash event
79 | mkdir c:\Crashdumps
80 | REG ADD "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v DumpFolder /t REG_EXPAND_SZ /d "c:\CrashDumps" /f
81 | REG ADD "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v CrashCount /t REG_DWORD /d 10 /f
82 | REG ADD "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v DumpType /t REG_DWORD /d 2 /f
83 | sc config WerSvc start= demand
84 |
85 | winmgmt /verifyrepository
86 |
--------------------------------------------------------------------------------
/scripts/puppet-enterprise.bat:
--------------------------------------------------------------------------------
1 | if not exist "C:\Windows\Temp\puppet.msi" (
2 | powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://pm.puppetlabs.com/puppet-enterprise/3.0.1/puppet-enterprise-3.0.1.msi', 'C:\Windows\Temp\puppet.msi')" > C:\Windows\Temp\PATH
9 | set /p PATH=> C:\Windows\Temp\PATH
9 | set /p PATH= /minion-name=
8 |
9 | > C:\Windows\Temp\PATH
10 | set /p PATH=
2 |
3 |
4 |
5 | 0
6 |
7 |
13 |
14 |
15 |
16 |
17 | true
18 | 3
19 | Work
20 | true
21 | true
22 | true
23 |
24 |
25 |
26 | vagrant
27 | true
28 |
29 | true
30 | 1
31 | vagrant
32 |
33 |
34 |
35 |
36 |
37 | vagrant
38 | false
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/scripts/vagrant-ssh.bat:
--------------------------------------------------------------------------------
1 | :: vagrant public key
2 | if exist a:\vagrant.pub (
3 | copy a:\vagrant.pub C:\Users\vagrant\.ssh\authorized_keys
4 | ) else (
5 | powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub', 'C:\Users\vagrant\.ssh\authorized_keys')" Skipping: $($Update.Title) because it requires user input"
71 | } else {
72 | if (!($Update.EulaAccepted)) {
73 | LogWrite "> Note: $($Update.Title) has a license agreement that must be accepted. Accepting the license."
74 | $Update.AcceptEula()
75 | [bool]$addThisUpdate = $true
76 | $script:CycleUpdateCount++
77 | } else {
78 | [bool]$addThisUpdate = $true
79 | $script:CycleUpdateCount++
80 | }
81 | }
82 |
83 | if ([bool]$addThisUpdate) {
84 | LogWrite "Adding: $($Update.Title)"
85 | $UpdatesToDownload.Add($Update) |Out-Null
86 | }
87 | }
88 | $script:i++
89 | }
90 |
91 | if ($UpdatesToDownload.Count -eq 0) {
92 | LogWrite "No Updates To Download..."
93 | } else {
94 | LogWrite 'Downloading Updates...'
95 | $ok = 0;
96 | while (! $ok) {
97 | try {
98 | $Downloader = $UpdateSession.CreateUpdateDownloader()
99 | $Downloader.Updates = $UpdatesToDownload
100 | $Downloader.Download()
101 | $ok = 1;
102 | } catch {
103 | LogWrite $_.Exception | Format-List -force
104 | LogWrite "Error downloading updates. Retrying in 30s."
105 | $script:attempts = $script:attempts + 1
106 | Start-Sleep -s 30
107 | }
108 | }
109 | }
110 |
111 | $UpdatesToInstall = New-Object -ComObject 'Microsoft.Update.UpdateColl'
112 | [bool]$rebootMayBeRequired = $false
113 | LogWrite 'The following updates are downloaded and ready to be installed:'
114 | foreach ($Update in $SearchResult.Updates) {
115 | if (($Update.IsDownloaded)) {
116 | LogWrite "> $($Update.Title)"
117 | $UpdatesToInstall.Add($Update) |Out-Null
118 |
119 | if ($Update.InstallationBehavior.RebootBehavior -gt 0){
120 | [bool]$rebootMayBeRequired = $true
121 | }
122 | }
123 | }
124 |
125 | if ($UpdatesToInstall.Count -eq 0) {
126 | LogWrite 'No updates available to install...'
127 | $global:MoreUpdates=0
128 | $global:RestartRequired=0
129 | & "a:\enable-winrm.ps1"
130 | break
131 | }
132 |
133 | if ($rebootMayBeRequired) {
134 | LogWrite 'These updates may require a reboot'
135 | $global:RestartRequired=1
136 | }
137 |
138 | LogWrite 'Installing updates...'
139 |
140 | $Installer = $script:UpdateSession.CreateUpdateInstaller()
141 | $Installer.Updates = $UpdatesToInstall
142 | $InstallationResult = $Installer.Install()
143 |
144 | LogWrite "Installation Result: $($InstallationResult.ResultCode)"
145 | LogWrite "Reboot Required: $($InstallationResult.RebootRequired)"
146 | LogWrite 'Listing of updates installed and individual installation results:'
147 | if ($InstallationResult.RebootRequired) {
148 | $global:RestartRequired=1
149 | } else {
150 | $global:RestartRequired=0
151 | }
152 |
153 | for($i=0; $i -lt $UpdatesToInstall.Count; $i++) {
154 | New-Object -TypeName PSObject -Property @{
155 | Title = $UpdatesToInstall.Item($i).Title
156 | Result = $InstallationResult.GetUpdateResult($i).ResultCode
157 | }
158 | LogWrite "Item: $($UpdatesToInstall.Item($i).Title)"
159 | LogWrite "Result: $($InstallationResult.GetUpdateResult($i).ResultCode)"
160 | }
161 |
162 | Check-ContinueRestartOrEnd
163 | }
164 |
165 | function Check-WindowsUpdates() {
166 | LogWrite "Checking For Windows Updates"
167 | $Username = $env:USERDOMAIN + "\" + $env:USERNAME
168 | LogWrite "Script: " + $ScriptPath + "`nScript User: " + $Username + "`nStarted: " + (Get-Date).toString()
169 |
170 | $script:UpdateSearcher = $script:UpdateSession.CreateUpdateSearcher()
171 | $script:successful = $FALSE
172 | $script:attempts = 0
173 | $script:maxAttempts = 12
174 | while(-not $script:successful -and $script:attempts -lt $script:maxAttempts) {
175 | try {
176 | $script:SearchResult = $script:UpdateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
177 | $script:successful = $TRUE
178 | } catch {
179 | LogWrite $_.Exception | Format-List -force
180 | LogWrite "Search call to UpdateSearcher was unsuccessful. Retrying in 10s."
181 | $script:attempts = $script:attempts + 1
182 | Start-Sleep -s 10
183 | }
184 | }
185 |
186 | if ($SearchResult.Updates.Count -ne 0) {
187 | $Message = "There are " + $SearchResult.Updates.Count + " more updates."
188 | LogWrite $Message
189 | try {
190 | for($i=0; $i -lt $script:SearchResult.Updates.Count; $i++) {
191 | LogWrite $script:SearchResult.Updates.Item($i).Title
192 | LogWrite $script:SearchResult.Updates.Item($i).Description
193 | LogWrite $script:SearchResult.Updates.Item($i).RebootRequired
194 | LogWrite $script:SearchResult.Updates.Item($i).EulaAccepted
195 | }
196 | $global:MoreUpdates=1
197 | } catch {
198 | LogWrite $_.Exception | Format-List -force
199 | LogWrite "Showing SearchResult was unsuccessful. Rebooting."
200 | $global:RestartRequired=1
201 | $global:MoreUpdates=0
202 | Check-ContinueRestartOrEnd
203 | LogWrite "Show never happen to see this text!"
204 | Restart-Computer
205 | }
206 | } else {
207 | LogWrite 'There are no applicable updates'
208 | $global:RestartRequired=0
209 | $global:MoreUpdates=0
210 | }
211 | }
212 |
213 | $script:ScriptName = $MyInvocation.MyCommand.ToString()
214 | $script:ScriptPath = $MyInvocation.MyCommand.Path
215 | $script:UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'
216 | $script:UpdateSession.ClientApplicationID = 'Packer Windows Update Installer'
217 | $script:UpdateSearcher = $script:UpdateSession.CreateUpdateSearcher()
218 | $script:SearchResult = New-Object -ComObject 'Microsoft.Update.UpdateColl'
219 | $script:Cycles = 0
220 | $script:CycleUpdateCount = 0
221 |
222 | if ($BeginWithRestart) {
223 | $global:RestartRequired = 1
224 | Check-ContinueRestartOrEnd
225 | }
226 |
227 | Check-WindowsUpdates
228 | if ($global:MoreUpdates -eq 1) {
229 | Install-WindowsUpdates
230 | } else {
231 | Check-ContinueRestartOrEnd
232 | }
233 |
--------------------------------------------------------------------------------
/vagrantfile-windows_10.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.define "Windows 10 Base Box"
8 | config.vm.box = "windows10base"
9 | config.vm.communicator = "winrm"
10 |
11 | # Admin user name and password
12 | config.winrm.username = "vagrant"
13 | config.winrm.password = "vagrant"
14 |
15 | config.vm.guest = :windows
16 | config.windows.halt_timeout = 15
17 |
18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true
19 |
20 | config.vm.provider :virtualbox do |v, override|
21 | #v.gui = true
22 | v.customize ["modifyvm", :id, "--memory", 2048]
23 | v.customize ["modifyvm", :id, "--cpus", 2]
24 | v.customize ["modifyvm", :id, "--vram", 128]
25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
27 | end
28 |
29 | config.vm.provider :vmware_fusion do |v, override|
30 | v.gui = true
31 | v.vmx["memsize"] = "2048"
32 | v.vmx["numvcpus"] = "2"
33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3"
34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false"
35 | v.vmx["RemoteDisplay.vnc.port"] = "5900"
36 | v.vmx["scsi0.virtualDev"] = "lsisas1068"
37 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "TRUE"
38 | v.vmx["mks.enable3d"] = "TRUE"
39 | v.vmx["mks.forceDiscreteGPU"] = "TRUE"
40 | v.vmx["gui.fullscreenatpoweron"] = "TRUE"
41 | v.vmx["gui.viewmodeatpoweron"] = "fullscreen"
42 | v.vmx["gui.lastPoweredViewMode"] = "fullscreen"
43 | v.vmx["sound.startconnected"] = "FALSE"
44 | v.vmx["sound.present"] = "FALSE"
45 | v.vmx["sound.autodetect"] = "TRUE"
46 | v.enable_vmrun_ip_lookup = false
47 | v.whitelist_verified = true
48 | v.vmx["hgfs.linkRootShare"] = "FALSE"
49 | end
50 |
51 | config.vm.provider :vmware_workstation do |v, override|
52 | v.gui = true
53 | v.vmx["memsize"] = "2048"
54 | v.vmx["numvcpus"] = "2"
55 | v.vmx["ethernet0.virtualDev"] = "vmxnet3"
56 | v.vmx["RemoteDisplay.vnc.enabled"] = "false"
57 | v.vmx["RemoteDisplay.vnc.port"] = "5900"
58 | v.vmx["scsi0.virtualDev"] = "lsisas1068"
59 | v.enable_vmrun_ip_lookup = false
60 | v.whitelist_verified = true
61 | v.vmx["hgfs.linkRootShare"] = "FALSE"
62 | end
63 |
64 | config.vm.provider "hyperv" do |v|
65 | v.cpus = 2
66 | v.maxmemory = 2048
67 | v.linked_clone = true
68 | end
69 |
70 | config.vm.provider :libvirt do |libvirt, override|
71 | libvirt.memory = 2048
72 | libvirt.cpus = 2
73 |
74 | # Use WinRM for the default synced folder; or disable it if
75 | # WinRM is not available. Linux hosts don't support SMB,
76 | # and Windows guests don't support NFS/9P/rsync
77 | # See https://github.com/Cimpress-MCP/vagrant-winrm-syncedfolders
78 | if Vagrant.has_plugin?("vagrant-winrm-syncedfolders")
79 | override.vm.synced_folder ".", "/vagrant", type: "winrm"
80 | else
81 | override.vm.synced_folder ".", "/vagrant", disabled: true
82 | end
83 |
84 | # Enable Hyper-V enlightments, see
85 | # https://blog.wikichoon.com/2014/07/enabling-hyper-v-enlightenments-with-kvm.html
86 | libvirt.hyperv_feature :name => 'stimer', :state => 'on'
87 | libvirt.hyperv_feature :name => 'relaxed', :state => 'on'
88 | libvirt.hyperv_feature :name => 'vapic', :state => 'on'
89 | libvirt.hyperv_feature :name => 'synic', :state => 'on'
90 | end
91 | end
92 |
--------------------------------------------------------------------------------
/validate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | for template in $(ls -1 *.json); do
4 | echo $template
5 | packer validate --only=vmware-iso --only=virtualbox-iso $template
6 | done
7 |
--------------------------------------------------------------------------------
/windows_10.json:
--------------------------------------------------------------------------------
1 | {
2 | "builders": [
3 | {
4 | "accelerator": "kvm",
5 | "boot_wait": "6m",
6 | "communicator": "winrm",
7 | "cpus": "2",
8 | "disk_size": "{{user `disk_size`}}",
9 | "floppy_files": [
10 | "{{user `autounattend`}}",
11 | "./floppy/WindowsPowershell.lnk",
12 | "./floppy/PinTo10.exe",
13 | "./scripts/fixnetwork.ps1",
14 | "./scripts/disable-screensaver.ps1",
15 | "./scripts/disable-winrm.ps1",
16 | "./scripts/enable-winrm.ps1",
17 | "./scripts/microsoft-updates.bat",
18 | "./scripts/win-updates.ps1"
19 | ],
20 | "headless": true,
21 | "iso_checksum": "{{user `iso_checksum_type`}}:{{user `iso_checksum`}}",
22 | "iso_url": "{{user `iso_url`}}",
23 | "memory": "2048",
24 | "output_directory": "windows_10-qemu",
25 | "qemuargs": [
26 | [
27 | "-drive",
28 | "file=windows_10-qemu/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1"
29 | ],
30 | [
31 | "-drive",
32 | "file={{ user `virtio_win_iso` }},media=cdrom,index=3"
33 | ]
34 | ],
35 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
36 | "type": "qemu",
37 | "vm_name": "windows_10",
38 | "winrm_password": "vagrant",
39 | "winrm_timeout": "{{user `winrm_timeout`}}",
40 | "winrm_username": "vagrant"
41 | },
42 | {
43 | "boot_wait": "6m",
44 | "communicator": "winrm",
45 | "configuration_version": "8.0",
46 | "cpus": "2",
47 | "disk_size": "{{user `disk_size`}}",
48 | "floppy_files": [
49 | "{{user `autounattend`}}",
50 | "./floppy/WindowsPowershell.lnk",
51 | "./floppy/PinTo10.exe",
52 | "./scripts/fixnetwork.ps1",
53 | "./scripts/disable-screensaver.ps1",
54 | "./scripts/disable-winrm.ps1",
55 | "./scripts/enable-winrm.ps1",
56 | "./scripts/microsoft-updates.bat",
57 | "./scripts/win-updates.ps1"
58 | ],
59 | "guest_additions_mode": "none",
60 | "iso_checksum": "{{user `iso_checksum_type`}}:{{user `iso_checksum`}}",
61 | "iso_url": "{{user `iso_url`}}",
62 | "memory": "2048",
63 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
64 | "switch_name": "{{user `switch_name`}}",
65 | "type": "hyperv-iso",
66 | "vm_name": "windows_10",
67 | "winrm_password": "vagrant",
68 | "winrm_timeout": "{{user `winrm_timeout`}}",
69 | "winrm_username": "vagrant"
70 | },
71 | {
72 | "boot_command": "",
73 | "boot_wait": "6m",
74 | "communicator": "winrm",
75 | "cpus": 2,
76 | "disk_adapter_type": "lsisas1068",
77 | "disk_size": "{{user `disk_size`}}",
78 | "disk_type_id": "{{user `disk_type_id`}}",
79 | "floppy_files": [
80 | "{{user `autounattend`}}",
81 | "./floppy/WindowsPowershell.lnk",
82 | "./floppy/PinTo10.exe",
83 | "./scripts/fixnetwork.ps1",
84 | "./scripts/disable-screensaver.ps1",
85 | "./scripts/disable-winrm.ps1",
86 | "./scripts/enable-winrm.ps1",
87 | "./scripts/microsoft-updates.bat",
88 | "./scripts/win-updates.ps1"
89 | ],
90 | "guest_os_type": "windows9-64",
91 | "headless": "{{user `headless`}}",
92 | "iso_checksum": "{{user `iso_checksum_type`}}:{{user `iso_checksum`}}",
93 | "iso_url": "{{user `iso_url`}}",
94 | "memory": 2048,
95 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
96 | "type": "vmware-iso",
97 | "version": 14,
98 | "vm_name": "windows_10",
99 | "vmx_data": {
100 | "RemoteDisplay.vnc.enabled": "false",
101 | "RemoteDisplay.vnc.port": "5900"
102 | },
103 | "vmx_remove_ethernet_interfaces": true,
104 | "vnc_port_max": 5980,
105 | "vnc_port_min": 5900,
106 | "winrm_password": "vagrant",
107 | "winrm_timeout": "{{user `winrm_timeout`}}",
108 | "winrm_username": "vagrant"
109 | },
110 | {
111 | "boot_command": "",
112 | "boot_wait": "6m",
113 | "communicator": "winrm",
114 | "cpus": 2,
115 | "disk_size": "{{user `disk_size`}}",
116 | "floppy_files": [
117 | "{{user `autounattend`}}",
118 | "./floppy/WindowsPowershell.lnk",
119 | "./floppy/PinTo10.exe",
120 | "./scripts/fixnetwork.ps1",
121 | "./scripts/disable-screensaver.ps1",
122 | "./scripts/disable-winrm.ps1",
123 | "./scripts/enable-winrm.ps1",
124 | "./scripts/microsoft-updates.bat",
125 | "./scripts/win-updates.ps1"
126 | ],
127 | "guest_additions_mode": "disable",
128 | "guest_os_type": "Windows10_64",
129 | "headless": "{{user `headless`}}",
130 | "iso_checksum": "{{user `iso_checksum_type`}}:{{user `iso_checksum`}}",
131 | "iso_url": "{{user `iso_url`}}",
132 | "memory": 2048,
133 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
134 | "type": "virtualbox-iso",
135 | "vm_name": "windows_10",
136 | "winrm_password": "vagrant",
137 | "winrm_timeout": "{{user `winrm_timeout`}}",
138 | "winrm_username": "vagrant"
139 | }
140 | ],
141 | "post-processors": [
142 | {
143 | "keep_input_artifact": false,
144 | "output": "windows_10_{{.Provider}}.box",
145 | "type": "vagrant",
146 | "vagrantfile_template": "vagrantfile-windows_10.template"
147 | }
148 | ],
149 | "provisioners": [
150 | {
151 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"",
152 | "remote_path": "/tmp/script.bat",
153 | "scripts": [
154 | "./scripts/vm-guest-tools.bat",
155 | "./scripts/enable-rdp.bat"
156 | ],
157 | "type": "windows-shell"
158 | },
159 | {
160 | "scripts": [
161 | "./scripts/debloat-windows.ps1"
162 | ],
163 | "type": "powershell"
164 | },
165 | {
166 | "restart_timeout": "{{user `restart_timeout`}}",
167 | "type": "windows-restart"
168 | },
169 | {
170 | "scripts": [
171 | "./scripts/set-powerplan.ps1",
172 | "./scripts/docker/disable-windows-defender.ps1"
173 | ],
174 | "type": "powershell"
175 | },
176 | {
177 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"",
178 | "remote_path": "/tmp/script.bat",
179 | "scripts": [
180 | "./scripts/pin-powershell.bat",
181 | "./scripts/compile-dotnet-assemblies.bat",
182 | "./scripts/set-winrm-automatic.bat",
183 | "./scripts/uac-enable.bat",
184 | "./scripts/dis-updates.bat",
185 | "./scripts/compact.bat"
186 | ],
187 | "type": "windows-shell"
188 | }
189 | ],
190 | "variables": {
191 | "autounattend": "./answer_files/10/Autounattend.xml",
192 | "disk_size": "61440",
193 | "disk_type_id": "1",
194 | "headless": "false",
195 | "iso_checksum": "eb4e1f00f8f2939b5fa02b4f8c708d1d6a0311a4f6c442243d8d9156cca5c512",
196 | "iso_checksum_type": "sha256",
197 | "iso_url": "Physical Product from Microsoft",
198 | "restart_timeout": "5m",
199 | "vhv_enable": "false",
200 | "virtio_win_iso": "~/virtio-win.iso",
201 | "winrm_timeout": "6h"
202 | }
203 | }
204 |
205 |
--------------------------------------------------------------------------------
/windows_10.json.original:
--------------------------------------------------------------------------------
1 | {
2 | "builders": [
3 | {
4 | "boot_wait": "6m",
5 | "communicator": "winrm",
6 | "cpus": "2",
7 | "disk_size": "{{user `disk_size`}}",
8 | "floppy_files": [
9 | "{{user `autounattend`}}",
10 | "./floppy/WindowsPowershell.lnk",
11 | "./floppy/PinTo10.exe",
12 | "./scripts/fixnetwork.ps1",
13 | "./scripts/disable-screensaver.ps1",
14 | "./scripts/disable-winrm.ps1",
15 | "./scripts/enable-winrm.ps1",
16 | "./scripts/microsoft-updates.bat",
17 | "./scripts/win-updates.ps1"
18 | ],
19 | "headless": true,
20 | "iso_checksum": "{{user `iso_checksum`}}",
21 | "iso_checksum_type": "{{user `iso_checksum_type`}}",
22 | "iso_url": "{{user `iso_url`}}",
23 | "memory": "2048",
24 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
25 | "type": "qemu",
26 | "accelerator": "kvm",
27 | "output_directory": "windows_10-qemu",
28 | "qemuargs": [
29 | [ "-drive", "file=windows_10-qemu/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1" ],
30 | [ "-drive", "file={{ user `virtio_win_iso` }},media=cdrom,index=3" ]
31 | ],
32 | "vm_name": "windows_10",
33 | "winrm_password": "vagrant",
34 | "winrm_timeout": "{{user `winrm_timeout`}}",
35 | "winrm_username": "vagrant"
36 | },
37 | {
38 | "boot_wait": "6m",
39 | "communicator": "winrm",
40 | "configuration_version": "8.0",
41 | "cpus": "2",
42 | "disk_size": "{{user `disk_size`}}",
43 | "floppy_files": [
44 | "{{user `autounattend`}}",
45 | "./floppy/WindowsPowershell.lnk",
46 | "./floppy/PinTo10.exe",
47 | "./scripts/fixnetwork.ps1",
48 | "./scripts/disable-screensaver.ps1",
49 | "./scripts/disable-winrm.ps1",
50 | "./scripts/enable-winrm.ps1",
51 | "./scripts/microsoft-updates.bat",
52 | "./scripts/win-updates.ps1"
53 | ],
54 | "guest_additions_mode": "none",
55 | "iso_checksum": "{{user `iso_checksum`}}",
56 | "iso_checksum_type": "{{user `iso_checksum_type`}}",
57 | "iso_url": "{{user `iso_url`}}",
58 | "memory": "2048",
59 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
60 | "switch_name": "{{user `switch_name`}}",
61 | "type": "hyperv-iso",
62 | "vm_name": "windows_10",
63 | "winrm_password": "vagrant",
64 | "winrm_timeout": "{{user `winrm_timeout`}}",
65 | "winrm_username": "vagrant"
66 | },
67 | {
68 | "boot_command": "",
69 | "boot_wait": "6m",
70 | "communicator": "winrm",
71 | "cpus": 2,
72 | "disk_adapter_type": "lsisas1068",
73 | "disk_size": "{{user `disk_size`}}",
74 | "disk_type_id": "{{user `disk_type_id`}}",
75 | "floppy_files": [
76 | "{{user `autounattend`}}",
77 | "./floppy/WindowsPowershell.lnk",
78 | "./floppy/PinTo10.exe",
79 | "./scripts/fixnetwork.ps1",
80 | "./scripts/disable-screensaver.ps1",
81 | "./scripts/disable-winrm.ps1",
82 | "./scripts/enable-winrm.ps1",
83 | "./scripts/microsoft-updates.bat",
84 | "./scripts/win-updates.ps1"
85 | ],
86 | "guest_os_type": "windows9-64",
87 | "headless": "{{user `headless`}}",
88 | "iso_checksum": "{{user `iso_checksum`}}",
89 | "iso_checksum_type": "{{user `iso_checksum_type`}}",
90 | "iso_url": "{{user `iso_url`}}",
91 | "memory": 2048,
92 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
93 | "type": "vmware-iso",
94 | "version": 14,
95 | "vm_name": "windows_10",
96 | "vmx_data": {
97 | "RemoteDisplay.vnc.enabled": "false",
98 | "RemoteDisplay.vnc.port": "5900"
99 | },
100 | "vmx_remove_ethernet_interfaces": true,
101 | "vnc_port_max": 5980,
102 | "vnc_port_min": 5900,
103 | "winrm_password": "vagrant",
104 | "winrm_timeout": "{{user `winrm_timeout`}}",
105 | "winrm_username": "vagrant"
106 | },
107 | {
108 | "boot_command": "",
109 | "boot_wait": "6m",
110 | "communicator": "winrm",
111 | "cpus": 2,
112 | "disk_size": "{{user `disk_size`}}",
113 | "floppy_files": [
114 | "{{user `autounattend`}}",
115 | "./floppy/WindowsPowershell.lnk",
116 | "./floppy/PinTo10.exe",
117 | "./scripts/fixnetwork.ps1",
118 | "./scripts/disable-screensaver.ps1",
119 | "./scripts/disable-winrm.ps1",
120 | "./scripts/enable-winrm.ps1",
121 | "./scripts/microsoft-updates.bat",
122 | "./scripts/win-updates.ps1"
123 | ],
124 | "guest_additions_mode": "disable",
125 | "guest_os_type": "Windows10_64",
126 | "headless": "{{user `headless`}}",
127 | "iso_checksum": "{{user `iso_checksum`}}",
128 | "iso_checksum_type": "{{user `iso_checksum_type`}}",
129 | "iso_url": "{{user `iso_url`}}",
130 | "memory": 2048,
131 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
132 | "type": "virtualbox-iso",
133 | "vm_name": "windows_10",
134 | "winrm_password": "vagrant",
135 | "winrm_timeout": "{{user `winrm_timeout`}}",
136 | "winrm_username": "vagrant"
137 | }
138 | ],
139 | "post-processors": [
140 | {
141 | "keep_input_artifact": false,
142 | "output": "windows_10_{{.Provider}}.box",
143 | "type": "vagrant",
144 | "vagrantfile_template": "vagrantfile-windows_10.template"
145 | }
146 | ],
147 | "provisioners": [
148 | {
149 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"",
150 | "remote_path": "/tmp/script.bat",
151 | "scripts": [
152 | "./scripts/vm-guest-tools.bat",
153 | "./scripts/enable-rdp.bat"
154 | ],
155 | "type": "windows-shell"
156 | },
157 | {
158 | "scripts": [
159 | "./scripts/debloat-windows.ps1"
160 | ],
161 | "type": "powershell"
162 | },
163 | {
164 | "restart_timeout": "{{user `restart_timeout`}}",
165 | "type": "windows-restart"
166 | },
167 | {
168 | "scripts": [
169 | "./scripts/set-powerplan.ps1",
170 | "./scripts/docker/disable-windows-defender.ps1"
171 | ],
172 | "type": "powershell"
173 | },
174 | {
175 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"",
176 | "remote_path": "/tmp/script.bat",
177 | "scripts": [
178 | "./scripts/pin-powershell.bat",
179 | "./scripts/compile-dotnet-assemblies.bat",
180 | "./scripts/set-winrm-automatic.bat",
181 | "./scripts/uac-enable.bat",
182 | "./scripts/dis-updates.bat",
183 | "./scripts/compact.bat"
184 | ],
185 | "type": "windows-shell"
186 | }
187 | ],
188 | "variables": {
189 | "autounattend": "./answer_files/10/Autounattend.xml",
190 | "disk_size": "61440",
191 | "disk_type_id": "1",
192 | "headless": "false",
193 | "iso_checksum": "eb4e1f00f8f2939b5fa02b4f8c708d1d6a0311a4f6c442243d8d9156cca5c512",
194 | "iso_checksum_type": "sha256",
195 | "iso_url": "Physical Product from Microsoft",
196 | "restart_timeout": "5m",
197 | "vhv_enable": "false",
198 | "winrm_timeout": "6h",
199 | "virtio_win_iso": "~/virtio-win.iso"
200 | }
201 | }
202 |
203 |
--------------------------------------------------------------------------------