billyjoel
Enthusiast
Enthusiast

CLI exclude vmnics from output

Jump to solution

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

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

Move to PowerCLI.

0 Kudos
LucD
Leadership
Leadership

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

billyjoel
Enthusiast
Enthusiast

Many thanks this worked Smiley Happy

0 Kudos