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
$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}
}
$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
}
}
Online access to the latest VMworld Sessions & Labs and online services.
Learn morePurchase credits to redeem training and consulting services online.
Buy Now