Skip to content

Instantly share code, notes, and snippets.

@ssugar
Last active August 29, 2015 14:14
Show Gist options
  • Save ssugar/cf1cfc1cbc733ff730f0 to your computer and use it in GitHub Desktop.
Save ssugar/cf1cfc1cbc733ff730f0 to your computer and use it in GitHub Desktop.
Create Vagrant Windows Box for HyperV Provider

Most of this is taken from here. It also has more in-depth info.

###Download ISO###

###Install OS###

During the install create user vagrant with password vagrant

###Initial WinRM Setup###

Winrm QuickConfig

###Set WinRM to Automatic###

WinRM will respond much faster if it's set to Automatic start instead of Automatic (Delayed) start. Not sure if any adverse effects.

###Configure WinRM###

From an elevated command prompt:

winrm set winrm/config/client/auth @{Basic="true"}
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}	

###Enable CredSSP Authentication###

From a powershell prompt:

Enable-WSManCredSSP -Force -Role Server

###Change Powershell Execution Policy### Set-ExecutionPolicy -ExecutionPolicy Unrestricted

###Remove Extra Packages###

Get the powershell script from here. Run it on the machine.

###Export the VM###

Export the VM from within HyperV, delete the snapshots folder, add a metadata.json file containing:

{ "provider": "hyperv" }

Tar the Virtual Hard Disks, Virtual Machines, and metadata.json file into an tarball. Rename the extension to .box.

###Import to Vagrant###

Change directory to where you have the .box file

vagrant box add nameofbox yourfile.box

###Call it from a vagrantfile###

config.vm.box = "nameofbox"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment