cody_bunch
Hot Shot
Hot Shot

Port Group Types

Jump to solution

Greetings Powershell VI-Toolkit folks!

Is there a way to tell what Type a port group is? Say a Service Console or VMKernel port group? This would be rather useful.

-Cody

-Cody Bunch http://professionalvmware.com
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Something quick and dirty.

It will show for an ESX host the switchname, portgroup and the portgroup type.

$net = Get-View -id (Get-VMHost -Name <ESX-name> | Get-View).ConfigManager.NetworkSystem
foreach($pg in $net.NetworkInfo.Portgroup){
  if($pg.Port -eq $null) {
    Write-Host $pg.Spec.VswitchName $pg.Spec.Name "Virtual Machine Port Group"}
  else {Write-Host $pg.Spec.VswitchName $pg.Spec.Name $pg.Port[0].Type}
}

Note that it will give a type of "host" for VMkernel port groups.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership

Something quick and dirty.

It will show for an ESX host the switchname, portgroup and the portgroup type.

$net = Get-View -id (Get-VMHost -Name <ESX-name> | Get-View).ConfigManager.NetworkSystem
foreach($pg in $net.NetworkInfo.Portgroup){
  if($pg.Port -eq $null) {
    Write-Host $pg.Spec.VswitchName $pg.Spec.Name "Virtual Machine Port Group"}
  else {Write-Host $pg.Spec.VswitchName $pg.Spec.Name $pg.Port[0].Type}
}

Note that it will give a type of "host" for VMkernel port groups.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
cody_bunch
Hot Shot
Hot Shot

Yeah... umm...

WOW

-Cody Bunch http://professionalvmware.com
0 Kudos
halr9000
Commander
Commander

He has that effect.

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
LucD
Leadership
Leadership

Well it seems my previous script was mostly "dirty", there is a problem with that script.

For the explanation of the problem see .

This should be a "working" script.


$netsystem = Get-View -id (Get-VMHost -Name <ESX-name> | Get-View).ConfigManager.NetworkSystem
$noVMnic = @{}
foreach($vnic in $netsystem.NetworkInfo.ConsoleVnic){ 
  $noVMnic[http://$vnic.Portgroup|http://$vnic.Portgroup] = $true
} 
foreach($vnic in $netsystem.NetworkInfo.Vnic){ 
  $noVMnic[http://$vnic.Portgroup|http://$vnic.Portgroup] = $true
} 
 
foreach($pg in $netsystem.NetworkInfo.Portgroup){ 
  if(! $noVMnic.ContainsKey($pg.Spec.Name)){
    Write-Host $pg.Spec.VswitchName $pg.Spec.Name "Virtual Machine Port Group"
  }
  else{
    Write-Host $pg.Spec.VswitchName $pg.Spec.Name $pg.Port[0].Type
  }
} 

Since the forum SW seems to have problems with square brackets I attached the script.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos