如何从 Vcenter 导出集群中所有 VM 的列表(VM 网络 VLAN id)?我没有看到任何网络详细信息选项。
使用 Vcenter 6.5
我试过这个选项。我只替换Get-VirtualPortGroup
为Get-VDPortgroup
,但不适用于我,有一些错误
$Portgroups = Get-VDPortgroup |Sort-Object -Unique
$Datastores = Get-Datastore |Sort-Object -Unique
$VMs = get-vm
[System.Collections.ArrayList]$Output = @()
foreach ($currentVM in $VMs) {
$VM = New-Object -TypeName PsObject
$VM | Add-Member -Membertype NoteProperty -Name "Name" -Value $currentVM.Name
foreach ($Portgroup in $Portgroups) {
$VM | Add-Member -MemberType NoteProperty -Name $Portgroup.Name -Value (($currentVM|Get-VDPortgroup).name -contains $Portgroup.Name)
}
foreach ($Datastore in $Datastores) {
$VM | Add-Member -MemberType NoteProperty -Name $Datastore.Name -Value (($currentVM|Get-Datastore).name -contains $Datastore.Name)
}
$Output += $VM
}
$Output |Export-Csv -Path "vm_export.csv"
错误:
Get-VDPortgroup : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:9 char:93
+ ... rty -Name $Portgroup.Name -Value (($currentVM|Get-VDPortgroup).name - ...
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (test-vm:PSObject) [Get-VDPortgroup], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.Vds.Commands.Cmdlets.GetVDPortgroup
您可以通过 PowerCLI 获取所需的所有信息。
将所有端口组和数据存储区作为单独的列使其变得更加复杂。这对我有用:
简单的方法是使用rvtool。只需将其安装在您的计算机上并保存 Excel 报告即可。然后,您可以根据需要进行过滤。