To run some Tests, I needed to create a bunch of different hosts, and I decided that I want to have new ones and no clones.

I just install a lot of throw-away hosts to run some update Tests (new Windows 10 Build), and I install them customized, so no clones and no automated setup.

Here is a quick script that helped me a lot to create all the Hyper-V Hosts for my Tests:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
<#
		.SYNOPSIS
		Create a simple Windows 10 VM
	
		.DESCRIPTION
		Create a simple Windows 10 VM for my Test-LAB
	
		.PARAMETER Client
		Client Name
	
		.PARAMETER Path
		Wher to create the new Disk Image?
		Default is: D:\Hyper-V\Virtual Hard Disks\
	
		.PARAMETER DiskSize
		Size of the new Disk in GB?
		Default is 100
	
		.PARAMETER StartMem
		Memory Size in GB?
		Deafult is: 2
	
		.PARAMETER VSwitch
		Hyper-V Switch to use?
		Default is: EXT (my external LAB Switch)
	
		.PARAMETER Generation
		Hyper-V VM Generation?
		The default is: 2
	
		.PARAMETER MaxMem
		Max RAM Size in MegaByte?
		The default is: 3072
	
		.PARAMETER Enterprise
		Use Enterprise Edition?
		The default is: NO (Then the PRO Image is used)
	
		.EXAMPLE
		PS C:\> win10vm.ps1 -Client 'LABWIN10V01'

		Create the new VM LABWIN10V01 with the Default settings
	
		.NOTES
		TODO: Merge this with my existsing Clone Script.
		TODO: Add the other Switches from the LAB Server
#>
param
(
	[Parameter(Mandatory = $true,
			Position = 1,
	HelpMessage = 'Client Name')]
	[ValidateNotNullOrEmpty()]
	[string]$Client,
	[ValidateNotNullOrEmpty()]
	[string]$Path = 'D:\Hyper-V\Virtual Hard Disks\',
	[ValidateNotNullOrEmpty()]
	[int]$DiskSize = 100,
	[ValidateNotNullOrEmpty()]
	[int]$StartMem = 2,
	[ValidateNotNullOrEmpty()]
	[String]$VSwitch = 'EXT',
	[ValidateNotNullOrEmpty()]
	[int]$Generation = 2,
	[int]$MaxMem = 3072,
	[switch]$Enterprise
)

# Where to create the Disk
$Target = $Path + $Client + '.vhdx'

# Create the Disk
$DiskImageSize = ($DiskSize * 1GB)
$null = (New-VHD -Path $Target -Fixed -SizeBytes $DiskImageSize)

# Create the VM, without a Disk. We attach the new disk later
$VMStartupMemeory = ($StartMem * 1GB)
$null = (New-VM -Name $Client -MemoryStartupBytes $VMStartupMemeory -NoVHD -SwitchName $VSwitch -Generation $Generation)

# Set the Memory settings
$VMMaximumBytes = ($MaxMem * 1MB)
$null = (Set-VMMemory -VMName $Client -DynamicMemoryEnabled $true -MaximumBytes $VMMaximumBytes)

# Attach the new Disk
$null = (Add-VMHardDiskDrive -VMName $Client -Path $Target)

# What kind of Windows 10 do we deploy here?
if ($Enterprise) {
	$null = (Add-VMDvdDrive -VMName $Client -Path 'C:\ISO\SW_DVD5_WIN_ENT_10_1511_64BIT_English_MLF_X20-82288.ISO')
} else {
	$null = (Add-VMDvdDrive -VMName $Client -Path 'C:\ISO\SW_DVD5_Win_Pro_10_1511_64BIT_English_MLF_X20-82416.ISO')
}

# Get the Adapter, Disk, DVD Settings
$network = (Get-VMNetworkAdapter -VMName $Client)
$vhd = (Get-VMHardDiskDrive -VMName $Client)
$dvd = (Get-VMDvdDrive -VMName $Client)

# Set the default Boot order
$null = (Set-VMFirmware -VMName $Client -BootOrder $vhd, $dvd, $network)

# Boot from the DVD on the 1st boot
$null = (Set-VMFirmware -VMName $Client -FirstBootDevice $dvd)

Feel free to improve it on GitHub!