Hiya,
I know my good will is probabily getting a bit short here but hey I shall ask!
I have several vcenters, with hundreds of vlans (literally)
What I need to do is to extract, per cluster:
Cluster name
Network ranges available within the cluster
VLAN ID
As I say, if anyone can provide a script to do that, it would be much appreciated.
Regards
Stu
Sure, capture the output in a variable and pipe that variable to the Export-Csv cmdlet.
$report = foreach($cluster in Get-Cluster){ foreach($esx in (Get-VMHost -Location $cluster)){ foreach($pg in (Get-VirtualPortgroup -VMHost $esx)){ Select -InputObject $pg @{N="Cluster";E={$cluster.Name}}, @{N="VMHost";E={$esx.Name}}, @{N="Portgroup";E={$pg.Name}}, @{N="VLAN";E={$pg.VlanId}}, @{N="IP";E={ $adapter = Get-VMHostNetworkAdapter -VMHost $esx | where {$_.PortgroupName -eq $pg.Name} if($adapter){ [string]::Join(',',($adapter.IP | %{$_})) } }} } } } $report | Export-Csv "C:\Temp\report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Use RVTOOL if you have not used before.. its a freeware.. which will fetch you the required information..under vNetwork and vSwitch column..
link to download rvtool
Award points by clicking the below tab if the answer is helpful and correct
You could try something like this
foreach($cluster in Get-Cluster){ foreach($esx in (Get-VMHost -Location $cluster)){ foreach($pg in (Get-VirtualPortgroup -VMHost $esx)){ Select -InputObject $pg @{N="Cluster";E={$cluster.Name}}, @{N="VMHost";E={$esx.Name}}, @{N="Portgroup";E={$pg.Name}}, @{N="VLAN";E={$pg.VlanId}}, @{N="IP";E={ $adapter = Get-VMHostNetworkAdapter -VMHost $esx | where {$_.PortgroupName -eq $pg.Name} if($adapter){ [string]::Join(',',($adapter.IP | %{$_})) } }} } } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Can it be exported in csv format all vlan info.
thanks
vmguy
Sure, capture the output in a variable and pipe that variable to the Export-Csv cmdlet.
$report = foreach($cluster in Get-Cluster){ foreach($esx in (Get-VMHost -Location $cluster)){ foreach($pg in (Get-VirtualPortgroup -VMHost $esx)){ Select -InputObject $pg @{N="Cluster";E={$cluster.Name}}, @{N="VMHost";E={$esx.Name}}, @{N="Portgroup";E={$pg.Name}}, @{N="VLAN";E={$pg.VlanId}}, @{N="IP";E={ $adapter = Get-VMHostNetworkAdapter -VMHost $esx | where {$_.PortgroupName -eq $pg.Name} if($adapter){ [string]::Join(',',($adapter.IP | %{$_})) } }} } } } $report | Export-Csv "C:\Temp\report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD !!