Hi,
Please help, I am seeing VM details twice in the output when connecting multiple vCenters
Script
Connect-viserver -Server (Get-Content .\VC_Info.txt) > $null
$VmInfo = Foreach ($vc in $global:DefaultVIServers) {
ForEach ($VM in (Get-Folder -Name Universal-Dev -Server $vc | Get-VM -Server $vc)) {
$VM.Extensiondata.Guest.Disk | Select @{N='vCenter'; E={([uri]$vm.ExtensionData.Client.ServiceUrl).Host}},
@{N="Name";E={$VM.Name}},
@{N = "IPAddress";E={$VM.guest.IPAddress[0]}},
@{N = "VM PowerState";E={@($VM.PowerState)}},
@{N = "Operating System";E={@($VM.guest.OSFullName)}},
@{N = "Folder";E={$VM.Folder.Name}}
}
}
$VmInfo | ft -auto
disconnect-viserver -server * -force -confirm:$false
Output
venter6x | app43 | 192.168.3.127 | PoweredOn Microsoft Windows Server 2016 or later (64-bit) Dev |
venter6x | app43 | 192.168.3.127 | PoweredOn Microsoft Windows Server 2016 or later (64-bit) Dev |
venter6x | app39 | 192.168.3.130 | PoweredOn Microsoft Windows Server 2016 or later (64-bit) Dev |
venter6x | app39 | 192.168.3.130 | PoweredOn Microsoft Windows Server 2016 or later (64-bit) Dev |