VMware Cloud Community
billyjoel
Enthusiast
Enthusiast
Jump to solution

CLI exclude vmnics from output

Hi all,

I have the belo line to retrive the network info of each host in a specific cluster:

get-cluster ClusterName | get-vmhost | Get-VMHostNetworkAdapter | select VMhost, Name, IP, SubnetMask, PortGroupName |  Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

The output looks like this:

pastedImage_1.png

I'm wondering how can I get rid of the first 6 rows? the vmnic ones, is there any parameter or option to exclude them from the output?

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use a where-clause

Get-Cluster -Name ClusterName |

Get-VMHost |

Get-VMHostNetworkAdapter |

where{$_.Name -notmatch "^vmnic"} |

select VMhost, Name, IP, SubnetMask, PortGroupName |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

But an easier solution might be

Get-Cluster -Name ClusterName |

Get-VMHost |

Get-VMHostNetworkAdapter -VMKernel |

select VMhost, Name, IP, SubnetMask, PortGroupName |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

View solution in original post

3 Replies
daphnissov
Immortal
Immortal
Jump to solution

Move to PowerCLI.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can use a where-clause

Get-Cluster -Name ClusterName |

Get-VMHost |

Get-VMHostNetworkAdapter |

where{$_.Name -notmatch "^vmnic"} |

select VMhost, Name, IP, SubnetMask, PortGroupName |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

But an easier solution might be

Get-Cluster -Name ClusterName |

Get-VMHost |

Get-VMHostNetworkAdapter -VMKernel |

select VMhost, Name, IP, SubnetMask, PortGroupName |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

billyjoel
Enthusiast
Enthusiast
Jump to solution

Many thanks this worked Smiley Happy

0 Kudos