Hi All,
I have written below script for getting host vSwitch Details and script works fine.
Get-VirtualPortGroup | select @{N='HostName';E={(Get-View -ID $_.VMHostID | select -expandproperty Name)}},VirtualSwitchName,Name,VLANId
Is there any way that we can get vmnic associated with vSwitch
if vSwitch1 is having 2 vmnic then it needs to print like
vmnic0 vSwitch1
vmnic1 vSwitch1
Try like this
foreach($pg in Get-VirtualPortGroup -Standard){
$pg.VirtualSwitch.Nic |
Select @{N='VMHost';E={$pg.VirtualSwitch.VMHost.Name}},
@{N='vSwitch';E={$pg.VirtualSwitch.Name}},
@{N='Portgroup';E={$pg.Name}},
@{N='VLanId';E={$pg.VLanId}},
@{N='pNIC';E={$_}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi All,
Can someone suggest me the right way of getting this report.
Try like this
foreach($pg in Get-VirtualPortGroup -Standard){
$pg.VirtualSwitch.Nic |
Select @{N='VMHost';E={$pg.VirtualSwitch.VMHost.Name}},
@{N='vSwitch';E={$pg.VirtualSwitch.Name}},
@{N='Portgroup';E={$pg.Name}},
@{N='VLanId';E={$pg.VLanId}},
@{N='pNIC';E={$_}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Lucd, Script works fine.