Hi All,
I wonder if it is possible to combine the below two PowerCLI line so the exported result can be in .CSV format ?
Get-VMHost | Sort Name | Select Name, @{N="NTP";E={Get-VMHostNtpServer $_}}
Get-VMHost | Get-VMHostNetwork
Thanks in advance.
Hello, AlbertWT-
It sure is! You can get those properties in a single returned object per VMHost like:
Get-VMHost | Get-VMHostNetwork | Select HostName, DomainName, DnsFromDhcp, `
ConsoleGateway, ConsoleGatewayDevice, DnsAddress, @{N="NTP";E={Get-VMHostNtpServer $_.VMHost}}
That should give you some goodness like (example for one server):
HostName : myesxi02
DomainName : mydom.com
DnsFromDhcp : False
ConsoleGateway :
ConsoleGatewayDevice :
DnsAddress : {172.16.0.13, 172.16.0.16, 8.8.4.4}
NTP : pool.ntp.org
Then, to export that to CSV, you just pipe all of that to Export-CSV, of course (add " | Export-Csv c:\temp\myFile.csv -NoTypeInformation" to the end of the line, without the quotes). That do it for you?
Hello, AlbertWT-
It sure is! You can get those properties in a single returned object per VMHost like:
Get-VMHost | Get-VMHostNetwork | Select HostName, DomainName, DnsFromDhcp, `
ConsoleGateway, ConsoleGatewayDevice, DnsAddress, @{N="NTP";E={Get-VMHostNtpServer $_.VMHost}}
That should give you some goodness like (example for one server):
HostName : myesxi02
DomainName : mydom.com
DnsFromDhcp : False
ConsoleGateway :
ConsoleGatewayDevice :
DnsAddress : {172.16.0.13, 172.16.0.16, 8.8.4.4}
NTP : pool.ntp.org
Then, to export that to CSV, you just pipe all of that to Export-CSV, of course (add " | Export-Csv c:\temp\myFile.csv -NoTypeInformation" to the end of the line, without the quotes). That do it for you?
mattboren,
Cool, many thanks for the quick reply.
Yes it works.
Why does the ConsoleGateway and ConsoleGatewayDevice property is always blank ?