How to Determine the current pNIC / standard switch uplink a VM is using by PowerCLI script?

In PowerCLI we have the Get-EsxTop, which retrieves the values displayed by esxtop. Indirectly this script is using certain values of esxtop command to get the exact input.

IM

NOTE: Please try testing this script first in a test environment before trying in Production. We do not take any responsibility for any issues if directly run in Production.

 

=================================================================================

$esxName = ‘myesx.domain’

$user = ‘root’

$pswd = ‘*******’

Connect-VIServer -Server $esxName -User $user -Password $pswd | Out-Null

$topo = Get-EsxTop -Topology NetPort -TopologyInfo

Get-EsxTop -Server $esxName -CounterName NetPort |

Select PortId, @{N = ‘Used-By’; E = { $_.ClientName } },

@{N = ‘Team-pNic’; E = { $_.TeamUplink } },

@{N = ‘DName’; E = {

$portId = $_.portId

($topo.Entries | where { $_.PortId -eq $portId }).PortsetName

}

}

Disconnect-VIServer -Server $esxName -Confirm:$false

===================================================================

 

You may also like...

Leave a Reply

%d bloggers like this: