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
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.
He has that effect.
Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Well it seems my previous script was mostly "dirty", there is a problem with that script.
For the explanation of the problem see Re: Get list of available networks on an ESX host.
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.