zoukankan      html  css  js  c++  java
  • PowerShell 在hyper-v中创建虚拟机

    # This script configures the Hyper-V machines used for the 50331 Course.
    # PowerShell 3.0 and Windows Server 2012 or Windows 8 Pro are required to perform this setup
    # The C: Drive should have at least 200GB of free space available.
    # All the files on the 50331 Student CD should be copied to C:Labfiles before performing this setup.
    # Variables
    $CLI1 = "test_client"        # Name of VM running Client Operating System
    $SRV1 = "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
    $CLI1VHD = 80GB                                # Size of Hard-Drive for Client Operating System
    $SRV1VHD = 40GB                                # Size of Hard-Drive for Server Operating System
    $VMLOC = "G:	est"                    # Location of the VM and VHDX files
    $NetworkSwitch1 = "vlan_out"    # Name of the Network Switch
    $W7ISO = "E:SoftwareMicrosoftcn_windows_server_2012_r2cn_windows_server_2012_r2_with_update_x64_dvd_6052725.iso"    # Windows 7 ISO
    $W7VFD = "G:Windows_Server_2012Virtual Hard DisksWindows_Server_2012.vhdx"    # Windows 7 Virtual Floppy Disk with autounattend.xml file
    $WSISO = "E:SoftwareMicrosoftcn_windows_server_2012_r2cn_windows_server_2012_r2_with_update_x64_dvd_6052725.iso"            # Windows Server 2008 ISO
    $WSVFD = "G:Windows_Server_2012Virtual Hard DisksWindows_Server_2012.vhdx"    # Windows Server 2008 Virtual Floppy Disk with autounattend.xml file
    
    # Create VM Folder and Network Switch
    MD $VMLOC -ErrorAction SilentlyContinue
    $TestSwitch = Get-VMSwitch -Name $NetworkSwitch1 -ErrorAction SilentlyContinue; if ($TestSwitch.Count -EQ 0){New-VMSwitch -Name $NetworkSwitch1 -SwitchType Private}
    
    # Create Virtual Machines
    New-VM -Name $CLI1 -Path $VMLOC -MemoryStartupBytes $CRAM -NewVHDPath $VMLOC$CLI1.vhdx -NewVHDSizeBytes $CLI1VHD -SwitchName $NetworkSwitch1
    New-VM -Name $SRV1 -Path $VMLOC -MemoryStartupBytes $SRAM -NewVHDPath $VMLOC$SRV1.vhdx -NewVHDSizeBytes $SRV1VHD -SwitchName $NetworkSwitch1
    
    # Configure Virtual Machines
    Set-VMDvdDrive -VMName $CLI1 -Path $W7ISO
    Set-VMDvdDrive -VMName $SRV1 -Path $WSISO
    Set-VMFloppyDiskDrive -VMName $CLI1 -Path $W7VFD
    Set-VMFloppyDiskDrive -VMName $SRV1 -Path $WSVFD
    Start-VM $SRV1
    Start-VM $CLI1
  • 相关阅读:
    C++操作文件行(读取,删除,修改指定行)
    Windows注册表中修改UAC(用户账号控制)及批处理脚本
    Centos7.x 安装libevent2.x
    【Docker】:使用docker安装redis,挂载外部配置和数据
    【Docker】:使用docker安装mysql,挂载外部配置和数据
    开源定时任务框架Quartz(二)
    开源定时任务框架Quartz(一)
    Spring Boot系列教程十四:Spring boot同时支持HTTP和HTTPS
    数据结构与算法:单向链表实现与封装(有头)
    【C++札记】指针函数与函数指针
  • 原文地址:https://www.cnblogs.com/wicrecend/p/4931415.html
Copyright © 2011-2022 走看看