使用Hyper-V PowerShell

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

在搜索中PowerShell並打開PowerShell

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

使用get-help幫助學習Hyper-V PowerShell

clip_image004

二、 使用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

clip_image009

更多Hyper-V PowerShell cmdlet部分請參見微軟官方網站:

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章