Automation

 View Only
  • 1.  CLI exclude vmnics from output

    Posted Mar 13, 2020 04:36 PM

    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:

    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?



  • 2.  RE: CLI exclude vmnics from output

    Posted Mar 13, 2020 04:38 PM

    Move to PowerCLI.



  • 3.  RE: CLI exclude vmnics from output
    Best Answer

    Posted Mar 13, 2020 05:16 PM

    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



  • 4.  RE: CLI exclude vmnics from output

    Posted Mar 16, 2020 03:34 PM

    Many thanks this worked :smileyhappy: