PowerCLI – 查詢/設定/重新啟動VMware Host NTP服務

參考資料
Setting ESXi DNS and NTP using PowerCLI

ESX(i) NTP Server settings: PowerCLI

$esxHosts = get-VMHost

foreach ($esx in $esxHosts) {
   Write-Host "Configuring NTP Client Policy on $esx" -ForegroundColor Green
   Get-VMHostService -VMHost $esx | where{$_.Key -eq "ntpd"} | Set-VMHostService -policy "on" -Confirm:$false

   Write-Host "Restarting NTP Client on $esx" -ForegroundColor Green
   Get-VMHostService -VMHost $esx | where{$_.Key -eq "ntpd"} | Restart-VMHostService -Confirm:$false

}

 

$vmhosts = Get-VMHost
$details = @()
foreach ($vmhost in $vmhosts) {
    $detail = "" | select Name,NTPServer
    $detail.Name = $vmhost.Name
    $detail.NTPServer = Get-VMHostNtpServer $vmhost
    $details += $detail
}

$details

 

Facebook Comments Box

Leave a Reply