PowerShell creates a virtual machine in Hyper-V

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.