一、 列出Hyper-V PowerShell命令行模块

在搜索中PowerShell并打开PowerShell

get-command –module hyper-v | out-gridview

使用get-help帮助学习Hyper-V PowerShell

使用Hyper-V PowerShell_Hyper-V

二、 使用PowerShell列出虚拟机

使用下面的命令列出正在运行的虚拟机

get-vm | where {$_.State –eq ‘Running’}

使用下面的命令列出已经关闭的虚拟机

get-vm | where {$_.State –eq ‘Off’}

三、 使用PowerShell创建虚拟机

使用管理员身份打开Windows PowerShell ISE

使用下面的命令创建虚拟机

$VMName = "Client01"
$VM = @{
    Name = $VMName
    MemoryStartupBytes = 2147483648
    Generation = 2
    NewVHDPath = " D:\Hyper-V\$VMName\$VMName.vhdx"
    NewVHDSizeBytes = 53687091200
    BootDevice = "VHD"
    Path = " D:\Hyper-V\$VMName "
    SwitchName = (get-vmswitch).Name[0]
}

New-VM @VM

使用Hyper-V PowerShell_PowerShell_02

更多Hyper-V PowerShell cmdlet部分请参见微软官方网站:

https://technet.microsoft.com/%5Clibrary/Hh848559.aspx