VMware Cloud Community
winsolo
Enthusiast
Enthusiast
Jump to solution

Obtaining VMs with multiple vNICs with their types, network names and connection state

How could we filter VMs that have multiple vNICs with their types, network names and connection state?

Snag_3d91171c.png

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Or did you mean filter on 2 or more vNICs?
Then this should do it

Get-VM | Get-NetworkAdapter |

Group-Object -Property {$_.Parent.Name} -PipelineVariable group |

where{$group.Group.Count -gt 1} |

ForEach-Object -Process {

    $group.Group |

    Select @{N='VM';E={$_.Parent.Name}},Name,

        @{N='Connected';E={$_.ConnectionState.Connected}},

        Type,NetworkName

} | Format-Table -AutoSize


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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

What exactly do you mean by "filter"?


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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Or did you mean filter on 2 or more vNICs?
Then this should do it

Get-VM | Get-NetworkAdapter |

Group-Object -Property {$_.Parent.Name} -PipelineVariable group |

where{$group.Group.Count -gt 1} |

ForEach-Object -Process {

    $group.Group |

    Select @{N='VM';E={$_.Parent.Name}},Name,

        @{N='Connected';E={$_.ConnectionState.Connected}},

        Type,NetworkName

} | Format-Table -AutoSize


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

0 Kudos
winsolo
Enthusiast
Enthusiast
Jump to solution

That's what I meant. It works. Thanks LucD

Snag_3dbfd6e2.png

0 Kudos