Highlighted
Enthusiast
Enthusiast

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

Jump to solution

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
Highlighted
User Moderator
User Moderator

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
Highlighted
User Moderator
User Moderator

What exactly do you mean by "filter"?


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

0 Kudos
Highlighted
User Moderator
User Moderator

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
Highlighted
Enthusiast
Enthusiast

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

Snag_3dbfd6e2.png

0 Kudos