AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / server / Perguntas / 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

como exportar a lista de todas as VMs (ID de VLANs de rede de VMs) no cluster do Vcenter?

  • 772

Como posso exportar a lista de todas as VMs (ID de VLANs de rede de VMs) no cluster do Vcenter? Não vejo nenhuma opção de detalhes da rede.

Usando o Vcenter 6.5

insira a descrição da imagem aqui

Eu tentei esta opção. Eu apenas substituí Get-VirtualPortGrouppara Get-VDPortgroup, mas não funciona para mim, recebi alguns erros

$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"

erro:

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 respostas
  • 49 Views

2 respostas

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

    Você pode obter todas as informações necessárias via 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"
    

    Obter todos os portgroups e datastores como colunas separadas torna isso um pouco mais complicado. Isso funciona para mim:

    $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

    A maneira mais fácil é usar rvtool . Basta instalá-lo em seu computador e salvar um relatório do Excel. Então você pode filtrar como quiser.

    • 1

relate perguntas

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Você pode passar usuário/passar para autenticação básica HTTP em parâmetros de URL?

    • 5 respostas
  • Marko Smith

    Ping uma porta específica

    • 18 respostas
  • Marko Smith

    Verifique se a porta está aberta ou fechada em um servidor Linux?

    • 7 respostas
  • Marko Smith

    Como automatizar o login SSH com senha?

    • 10 respostas
  • Marko Smith

    Como posso dizer ao Git para Windows onde encontrar minha chave RSA privada?

    • 30 respostas
  • Marko Smith

    Qual é o nome de usuário/senha de superusuário padrão para postgres após uma nova instalação?

    • 5 respostas
  • Marko Smith

    Qual porta o SFTP usa?

    • 6 respostas
  • Marko Smith

    Linha de comando para listar usuários em um grupo do Windows Active Directory?

    • 9 respostas
  • Marko Smith

    O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL?

    • 3 respostas
  • Marko Smith

    Como determinar se uma variável bash está vazia?

    • 15 respostas
  • Martin Hope
    Davie Ping uma porta específica 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    kernel O scp pode copiar diretórios recursivamente? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh retorna "Proprietário incorreto ou permissões em ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil Como automatizar o login SSH com senha? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin Como lidar com um servidor comprometido? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner Como posso classificar a saída du -h por tamanho 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent Como determinar se uma variável bash está vazia? 2009-05-13 09:54:48 +0800 CST

Hot tag

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

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve