我正在编写一个脚本来启动VM,如果它当前没有运行.我知道这样做的命令,但我的语法有问题.
在此脚本中,我想选择一个虚拟机,如果它处于关闭状态,我的脚本就会启动它,但如果虚拟机处于打开状态,则脚本会显示一条消息"虚拟机正在运行".
这时我写了一个脚本,但语法不正确:
if (Get-VM | Format-Table name, state -eq running) {
Write-Host -ForegroundColor red "VM running
}
else(start-vm -name "name")
Run Code Online (Sandbox Code Playgroud) powershell ×1