需要管理员权限,否则get-vm时,没有返回值,也不会报错。 下面就用简单的命令,完成简单的管理:

#列出所有相关网卡
Get-VMNetworkAdapter -all

#列出所有虚拟机
Get-VM  –VMname *

#获取指定虚拟机
Get-VM -Name 'windows-1'
 
#启动指定虚拟机
Get-VM -Name 'windows-1' | Start-VM
 
#暂停指定虚拟机
Get-VM -Name 'windows-1' | Suspend-VM
 
#恢复指定虚拟机
Get-VM -Name 'windows-1' | Resume-VM
 
#保存指定虚拟机
Get-VM -Name 'windows-1' | Save-VM
 
#关闭指定虚拟机
Get-VM -Name 'windows-1' | Stop-VM