Create Windows 10 Vagrant Base Box

In the first part I have shown how to create the Windows 10 VirtualBox VM. This time I will show you how to create a Vagrant Base Box.

Preconditions

Important Windows 10 Settings

Turn off and disable UAC (here you will find different ways)

disable windows 10 uac

Enable Remote Desktop

remote desktop settings

Configure WinRM on Windows

open the Command Prompt as Admin

> winrm quickconfig -q
> winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
> winrm set winrm/config @{MaxTimeoutms="1800000"}
> winrm set winrm/config/service @{AllowUnencrypted="true"}
> winrm set winrm/config/service/auth @{Basic="true"}
> sc config WinRM start=auto

Optional Settings for Windows

open the PowerShell as Admin

# remove all of the metro apps
> Get-AppXPackage -AllUsers | Remove-AppXPackage

# remove log files
> Get-Childitem "C:\Windows\Logs\dosvc" | Remove-Item -Verbose

# disables the system restore feature
> Disable-ComputerRestore c:

# disable hibernation
> powercfg -h off

# allow Powershell scripts to provision
> Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Okay,… that is all. Now shutdown windows…

Create Vagrant BaseBox

# goto default directory
$ cd VirtualBox\ VMs/

# create base box from VM
$ vagrant package --base Win10x64 --output Win10x64.box

# add box
$ vagrant box add lupin/windows10 Win10x64.box

# check vagrant boxes
$ vagrant box list

Create and run test project

# create project folder
$ mkdir ~/test_project && cd ~/test_project

# initializes to be a Vagrant environment
$ vagrant init lupin/windows10

# edit Vagrantfile
$ vim Vagrantfile

# start VM
$ vagrant up

# start rdp client
$ vagrant rdp
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

  config.vm.box = "lupin/windows10"
  config.vm.guest = :windows
  config.vm.communicator = "winrm"
  config.winrm.username = "vagrant"
  config.winrm.password = "vagrant"
  config.vm.boot_timeout = 600
  config.vm.network :forwarded_port, guest: 3389, host: 3389
  config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true

  config.vm.provider "virtualbox" do |vb|
    # vb.gui = true
    vb.memory = "2048"
    vb.cpus = 2
    vb.name = "Windows_Vagrant"
  end

end

Values for username and password should match your needs!