Created
January 31, 2019 21:28
-
-
Save chris1984/669bcd87473aed1d606a526fd7be8447 to your computer and use it in GitHub Desktop.
vmware-info.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Connect-VIServer -Server <vcenterfqdn> -User <adminuser> -Password <adminpassword> | |
Write-Host "Gathering clusters and ESXi hosts" | |
$sleep = 1 | |
Get-Cluster | |
Get-VMHost | Select Name, @{N="Cluster";E={Get-Cluster -VMHost $_}} | |
Write-Host "------------Finish Cluster/ESXi collection--------" | |
Write-Host "Gathering information on Distributed Switches" | |
$sleep = 1 | |
Get-VDSwitch | |
Write-Host "------------Finish Switch collection--------" | |
Write-Host "Gathering Host and Network info" | |
$sleep = 1 | |
&{foreach($esx in Get-VMHost){ | |
$vNicTab = @{} | |
$esx.ExtensionData.Config.Network.Vnic | %{ | |
$vNicTab.Add($_.Portgroup,$_) | |
} | |
foreach($vsw in (Get-VirtualSwitch -VMHost $esx)){ | |
foreach($pg in (Get-VirtualPortGroup -VirtualSwitch $vsw)){ | |
Select -InputObject $pg -Property @{N="ESX";E={$esx.name}}, | |
@{N="vSwitch";E={$vsw.Name}}, | |
@{N="NIC";E={if($vsw.Nic){[string]::Join(',',$vsw.Nic)}}}, | |
@{N="Portgroup";E={$pg.Name}}, | |
@{N="VLAN";E={$pg.VLanId}} | |
} | |
} | |
}} | |
Write-Host "------------Finish Host/Network collection--------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment