Hello,
Does anyone have a script to get the VDS information on the host level as to which nic is connected to which uplink ?
Also to remove any portgroups created in the VDS switch for the host and then to recreate the portgroups as they were after connecting the host to a diff vCenter ?
Also any script to copy the resource pools across VCenter ?
Thanks,
Suraj Rawat
The following script will export the VDS information for the uplinks, the port they are on and which pNIC is used per ESXi node.
$report = foreach($dvSw in Get-VDSwitch){
foreach($esx in (Get-View -id $dvSw.ExtensionData.Summary.HostMember)){
$proxy = $esx.Config.Network.ProxySwitch | where{$_.DvsUuid -eq $dvSw.ExtensionData.Uuid}
$pnicTab = @{}
$proxy.Spec.Backing.PnicSpec | %{
$pnicTab.Add($_.UplinkPortKey,$_.PnicDevice)
}
$proxy.UplinkPort |
Select @{N='vdSwitch';E={$dvSw.Name}},
@{N='VMHost';E={$esx.Name}},
@{N='vNIC';E={$pnicTab[$_.Key]}},
@{N='Uplink';E={$_.Value}},
@{N='Port';E={$_.Key}}
}
}
$report | Export-Csv C:\dvSw-Uplink.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Have a look on below posts/scripts
VDS Information - Re: PowerCLI to extract all vSwitch network info to CSV
Remove PortGroups - http://www.it-specialist.nu/powercli/remove-virtual-portgroup-from-hosts-in-a-datacenter
Add PortGroups - http://www.vspecialist.co.uk/adding-new-portgroups/
The following script will export the VDS information for the uplinks, the port they are on and which pNIC is used per ESXi node.
$report = foreach($dvSw in Get-VDSwitch){
foreach($esx in (Get-View -id $dvSw.ExtensionData.Summary.HostMember)){
$proxy = $esx.Config.Network.ProxySwitch | where{$_.DvsUuid -eq $dvSw.ExtensionData.Uuid}
$pnicTab = @{}
$proxy.Spec.Backing.PnicSpec | %{
$pnicTab.Add($_.UplinkPortKey,$_.PnicDevice)
}
$proxy.UplinkPort |
Select @{N='vdSwitch';E={$dvSw.Name}},
@{N='VMHost';E={$esx.Name}},
@{N='vNIC';E={$pnicTab[$_.Key]}},
@{N='Uplink';E={$_.Value}},
@{N='Port';E={$_.Key}}
}
}
$report | Export-Csv C:\dvSw-Uplink.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference