Skip to content

Instantly share code, notes, and snippets.

@nzbart
Created April 7, 2014 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nzbart/10014633 to your computer and use it in GitHub Desktop.
Save nzbart/10014633 to your computer and use it in GitHub Desktop.
Create a Hyper-V virtual machine for a VHD downloaded from http://modern.ie
$vhd = ls *.vhd | select -ExpandProperty Name
if(!$vhd -or $vhd.GetType().FullName -ne 'System.String') {
throw "Expected to find the VHD in the current directory."
}
$vmName = [System.IO.Path]::GetFileNameWithoutExtension($vhd)
Write-Host "Creating VM called $vmName..."
$newVm = New-VM -Name $vmName -MemoryStartupBytes 1024MB -SwitchName External -VHDPath (Resolve-Path $vhd) -Path . -Generation 1 -BootDevice IDE
$newVm | Set-VMProcessor -Count 2
$newVm | Set-VMMemory -DynamicMemoryEnabled $true -Buffer 100
$newVm | Start-VM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment