2 Replies Latest reply on Mar 27, 2017 8:07 PM by AlbertWT

    Combining the PowerCLI result for NTP and DNS server to .CSV file ?

    AlbertWT Master

      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.

        • 1. Re: Combining the PowerCLI result for NTP and DNS server to .CSV file ?
          mattboren Master
          vExpert

          Hello, -

           

          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?

          • 2. Re: Combining the PowerCLI result for NTP and DNS server to .CSV file ?
            AlbertWT Master

            mattboren,

             

            Cool, many thanks for the quick reply.

            Yes it works.

             

            Why does the ConsoleGateway and ConsoleGatewayDevice property is always blank ?