How to: Create a VM within a few second in Hyper-V 2012 R2

In some cases I’ve to create multiple VM’s within my Hyper-V environment. You can choose to create and configure each VM manually, but you can also use PowerShell. Now you can see how powerfull PowerShell really is! I’ve created multiple VM’s within a few seconds and ready to rock! I’ve created the following script. The only thing you’ve to do, is changing some variables 🙂

In this example the script will create a new VM named RES-MGN01. The VM will be configured with 2 GB, using Dynamic Memory. The VM is using a differencing disk (VHDK) with a Windows Server 2012 R2 sysprepped parent VHDX, placed on an SSD disk (P: drive) in my server. The virtual switch the VM is connected to, is named NIC – WAN.

$VMName = “RES-MGN01”
$VMMemMaxBytes = 2048MB
$VHDXName = “OS.vhdx”
$VMMemStartup = 512MB
$VMMemMinBytes = 512MB
$VMPath = “E:\”
$VHDParent = “P:\Hyper-V Parents\TMPL-W2012R2DC\Virtual Hard Disks\TMPL-W2012R2DC.vhdx”
$VMSwitchName = “NIC – WAN”

New-VM -Name $VMName -Path $VMpath$VMName -Generation 2 -SwitchName $VMSwitchName

Set-VM -Name $VMName -DynamicMemory -MemoryStartupBytes 512MB -MemoryMinimumBytes $VMMemMinBytes -MemoryMaximumBytes $VMMemMaxBytes

New-VHD -ParentPath $VHDParent -Path $VMPath\$VMName\$VMName\$VHDXName -Differencing

Add-VMHardDiskDrive -VMName $VMName -Path $VMPath\$VMName\$VMName\$VHDXName

Add-VMDvdDrive -VMName $VMName

Start-VM -Name $VMName

2014-01-14_11h48_41    2014-01-14_11h49_20    2014-01-14_11h50_27

2014-01-14_11h51_18    2014-01-14_11h52_12

Windows 8 Client Hyper-V copy/paste

A new feature within Windows 8 is Client Hyper-V. So within our Client OS you can run Hyper-V, that’s cool!! When you want to copy and paste some text, for example a script, this is not that easy as drag and drop or copy/paste! Is it possible? Yes, absolutely!!

The thing you need to do is copy the text on your local system, navigate back to your quest machine (VM), select the clipboard tab and hit Type clipboard text. Now you text is copied from the local machine into your quest machine!

2013-04-26_17h05_17    2013-04-26_17h09_35