无法使用(Get-VMHost).NetworkInfo获取IP,Mac和其他networking信息

我正在使用powerCLI verion 5.5,我写了下面的脚本: –

Get-VMHost |Export-Csv -Path c:\test.csv -NoTypeInformation –UseCulture 

我得到了vmhost的信息,如使用内存,构build,状态,CPU速度等,但对于生成的.csv文件中的networkinfo部分,我得到了“localhost”而不是VMHostnetworking信息。 所以我写了下面的脚本来获取IP,MAC和其他networking信息: –

 (Get-VMHost).NetworkInfo | Export-Csv -Path c:\test2.csv -NoTypeInformation -UseCulture 

但是我只能得到这些信息,我无法获得VMHOst的IP,MAC: –

 VMHostId VMHost VMKernelGateway VMKernelGatewayDevice ConsoleGateway ConsoleGatewayDevice DnsAddress DnsFromDhcp DnsDhcpDevice DomainName HostName SearchDomain VirtualSwitch PhysicalNic ConsoleNic VirtualNic Uid IPv6Enabled ConsoleV6Gateway ConsoleV6GatewayDevice VMKernelV6Gateway VMKernelV6GatewayDevice ExtensionData ExtensionData2 HostSystem-ha-host ******.intra 172.16.20.1 FALSE localhost VMware.VimAutomation.ViCore.Interop.V1.Host.Networking.VirtualSwitchInterop[] VMware.VimAutomation.ViCore.Interop.V1.Host.Networking.Nic.PhysicalNicInterop[] VMware.VimAutomation.ViCore.Interop.V1.Host.Networking.Nic.HostVirtualNicInterop[] VMware.VimAutomation.ViCore.Interop.V1.Host.Networking.Nic.HostVirtualNicInterop[] /VIServer=root@****************:443/VMHost=HostSystem-ha-host/VMHostNetwork=/ FALSE VMware.Vim.HostNetworkInfo VMware.Vim.HostNetworkSystem 

所以任何人都可以build议如何获得networking信息的vmhost? 这应该做为一个单独的脚本,或者我可以在我的原始脚本Get-VMHost?

您可能想要使用Get-VMHostNetworkAdapter cmdlet 。

特别是使用-VMKernel交换机来获取主机的pipe理接口。

像这样的东西:

 Get-VMHost <hostname> | Get-VMHostNetworkAdapter -VMKernel