Skip to content

Instantly share code, notes, and snippets.

@tomtorggler
Last active March 22, 2016 20:01
Show Gist options
  • Save tomtorggler/731a4ebc7233683ff894 to your computer and use it in GitHub Desktop.
Save tomtorggler/731a4ebc7233683ff894 to your computer and use it in GitHub Desktop.
# Create VMs on a host and add them to the cluster
1..4 | ForEach-Object {
# create differencing VHD for the VM
$vhdParams = @{
Differencing = $true;
ParentPath = "c:\clusterstorage\volume1\hyper-v\vhd\win2012r2.vhdx";
Path = "c:\clusterstorage\volume1\hyper-v\vhd\hcvm0$_.vhdx";
ComputerName = "n01"
}
New-VHD @vhdParams
# create the VM and add to cluster
$vmParams = @{
VHDPath = "C:\ClusterStorage\Volume1\Hyper-V\VHD\hcvm0$_.vhdx";
ComputerName = "n01";
Generation = 1;
MemoryStartupBytes = 1gb;
Name = "hcvm0$_";
Path = "C:\ClusterStorage\Volume1\Hyper-V";
SwitchName = "sw-ext"
}
New-VM @vmParams | Add-ClusterVirtualMachineRole -Cluster hc01
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment