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?
You can use a where-clause
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-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
Move to PowerCLI.
You can use a where-clause
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-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
Many thanks this worked