AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1112465
Accepted
andrew
andrew
Asked: 2022-10-08 00:46:55 +0800 CST2022-10-08 00:46:55 +0800 CST 2022-10-08 00:46:55 +0800 CST

如何从 Vcenter 导出集群中所有虚拟机列表(虚拟机网络 VLAN id)?

  • 772

如何从 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
vmware-esxi
  • 2 2 个回答
  • 49 Views

2 个回答

  • Voted
  1. Best Answer
    Gerald Schneider
    2022-10-08T01:27:16+08:002022-10-08T01:27:16+08:00

    您可以通过 PowerCLI 获取所需的所有信息。

    Get-Cluster cluster |
        Get-vm |Get-NetworkAdapter |
        Select Parent,NetworkName,@{name='VlanID';e={(Get-VirtualPortgroup -Name $_.NetworkName |select -First 1).vlanid}} |
        Export-Csv -Path "vm_export.csv"
    

    将所有端口组和数据存储区作为单独的列使其变得更加复杂。这对我有用:

    $Portgroups = Get-VirtualPortGroup |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-VirtualPortGroup).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"
    
    • 1
  2. Juan Herrera
    2022-10-11T09:02:48+08:002022-10-11T09:02:48+08:00

    简单的方法是使用rvtool。只需将其安装在您的计算机上并保存 Excel 报告即可。然后,您可以根据需要进行过滤。

    • 1

相关问题

  • ESXi NAS 配置

  • 如何将 Acronis 生成的 vmdk 添加到 esxi?

  • 在 VMWare ESX 和 ESXi 之间进行选择 [关闭]

  • 将(大)虚拟机从 ESXi 3.5 转换为 Hyper-V Server 2008 R2

  • VMWare:ESX 还是 3i?我需要COS吗?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve