PowerCLI

 View Only
  • 1.  Checking NTP/DNS Report

    Posted Jul 27, 2016 08:57 PM

    Hey all,

    I am looking for a script that would check the NTP services status on vHosts and if possible print out what time the vHost thinks it is.  Then on top of that print out what the vHosts has for the DNS server settings?

    So what I am looking for:

    NTP Service Status          Time               DNS Server Setting

    Let me know if this is possible, thanks!



  • 2.  RE: Checking NTP/DNS Report

    Posted Jul 28, 2016 05:05 AM

    Try like this

    Get-VMHost | Select Name,

        @{N='NTP Service Running';E={Get-VMHostService -VMHost $_ | where{$_.Key -eq 'ntpd'} | select -ExpandProperty Running}},

        @{N='DNS Server(s)';E={$_.Extensiondata.Config.Network.DnsConfig.Address -join ' | '}}



  • 3.  RE: Checking NTP/DNS Report

    Posted Jul 28, 2016 02:06 PM

    That worked for the most part but did not report the time itself.



  • 4.  RE: Checking NTP/DNS Report
    Best Answer

    Posted Jul 28, 2016 04:13 PM

    Oops, forgot that one.

    Try like this

    Get-VMHost | Select Name,

        @{N='NTP Service Running';E={Get-VMHostService -VMHost $_ | where{$_.Key -eq 'ntpd'} | select -ExpandProperty Running}},

        @{N='DNS Server(s)';E={$_.Extensiondata.Config.Network.DnsConfig.Address -join ' | '}},

        @{N='Time';E={(Get-View -Id $_.ExtensionData.ConfigManager.DatetimeSystem).QueryDateTime()}}



  • 5.  RE: Checking NTP/DNS Report

    Posted May 29, 2017 02:29 PM

    Hello Lucd,

    I have seen your other posts for creating a scheduled task to generate , need help on creating a scheduled task.

    And the one below is reporting the status of NTP service but i need alarms generated if in case the ntp service is stopped.

    Is there any way that can be done?

    Get-VMHost | Select Name,

    @{N='NTP Service Running';E={Get-VMHostService -VMHost $_ | where{$_.Key -eq 'ntpd'} | select -ExpandProperty Running}}

    Thanks,

    vikram M



  • 6.  RE: Checking NTP/DNS Report

    Posted May 29, 2017 04:39 PM

    Afaik, there is no event fired when an ESXi service is stopped or started.

    The only way to have this implemented would be to run a script in the background (scheduled), that checks the status of the service.

    And warns you when the service is not running (by email for example)