如何使用 powershell 命令获取 SCVMM 中的可用主机列表

How to get List of available hosts in SCVMM using powershell command

应该 return 只是 SCVMM 中可用的主机列表,而不是详细信息。

[https://docs.microsoft.com/en-us/powershell/module/virtualmachinemanager/get-scvmhost?view=systemcenter-ps-2019][1]

使用此脚本,您将获得主机列表以及第一个主机的详细信息。

为了 运行 这个脚本你需要 VMM powershell 模块,它只在安装了 VMM 控制台的地方可用。

## Import VMM module

Import-Module VirtualMachineManager

## Get the VMM server
Get-VMMServer "vmm.contoso.com" | out-null

## Get all hosts managed by the VMM server.
$Hosts = Get-SCVMHost

## Print the hosts list
Write-Host $Hosts

## With this line you gonna print all the attributes of the first host:
$Hosts[0]