#This script configures the Hyper-V machines used for the 50331 Course.#PowerShell 3.0 and Windows Server or Windows 8 Pro is required to perform this setup#The C + + Drive should has at least 200GB of free space available.#All the files on the 50331 Student CD should is copied to C:\Labfiles before performing this setup.#Variables$CLI 1="test_client" #Name of VM running Client Operating System$SRV 1="Test_server" #Name of VM running Server Operating System$CRAM= 4GB#RAM assigned to Client Operating System$SRAM= 2GB#RAM assigned to Server Operating System$CLI 1VHD= 80GB#Size of hard-drive for Client Operating System$SRV 1VHD= 40GB#Size of hard-drive for Server Operating System$VMLOC="G:\test" #Location of the VM and VHDX files$NetworkSwitch 1="Vlan_out" #Name of the Network Switch$W 7ISO="E:\Software\Microsoft\cn_windows_server_2012_r2\cn_windows_server_2012_r2_with_update_x64_dvd_6052725.iso " #Windows 7 ISO$W 7VFD="G:\Windows_Server_2012\Virtual Hard DISKS\WINDOWS_SERVER_2012.VHDX" #Windows 7 Virtual floppy Disk with Autounattend.xml file$WSISO="E:\Software\Microsoft\cn_windows_server_2012_r2\cn_windows_server_2012_r2_with_update_x64_dvd_6052725.iso " #Windows Server ISO$WSVFD="G:\Windows_Server_2012\Virtual Hard DISKS\WINDOWS_SERVER_2012.VHDX" #Windows Server Virtual floppy Disk with Autounattend.xml file#Create VM Folder and Network SwitchMd$VMLOC-erroraction silentlycontinue$TestSwitch= Get-vmswitch-name$NetworkSwitch 1-erroraction silentlycontinue;if($TestSwitch. Count-eq0) {New-vmswitch-name$NetworkSwitch 1-Switchtype Private}#Create Virtual MachinesNew-vm-name$CLI 1-path$VMLOC-memorystartupbytes$CRAM-newvhdpath$VMLOC\$CLI 1. vhdx-newvhdsizebytes$CLI 1VHD-switchname$NetworkSwitch 1New-vm-name$SRV 1-path$VMLOC-memorystartupbytes$SRAM-newvhdpath$VMLOC\$SRV 1. vhdx-newvhdsizebytes$SRV 1VHD-switchname$NetworkSwitch 1#Configure Virtual MachinesSet-vmdvddrive-vmname$CLI 1-path$W 7ISOSet-vmdvddrive-vmname$SRV 1-path$WSISOSet-vmfloppydiskdrive-vmname$CLI 1-path$W 7VFDSet-vmfloppydiskdrive-vmname$SRV 1-path$WSVFDStart-vm$SRV 1Start-vm$CLI 1
PowerShell creates a virtual machine in Hyper-V