{"id":458,"date":"2010-06-17T20:42:08","date_gmt":"2010-06-17T19:42:08","guid":{"rendered":"http:\/\/www.amikkelsen.com\/?p=458"},"modified":"2010-06-17T20:53:16","modified_gmt":"2010-06-17T19:53:16","slug":"powershell-configure-ntp-server-list","status":"publish","type":"post","link":"https:\/\/www.amikkelsen.com\/?p=458","title":{"rendered":"Powershell &#8211; Configure NTP server list"},"content":{"rendered":"<p>If you want to configure a hosts NTP server list through PowerCLI you have a few cmdlet at your disposal.<\/p>\n<ul>\n<li>Get-VMHostNtpServer<\/li>\n<li>Remove-VMHostNtpServer<\/li>\n<li>Add-VMHostNtpServer<\/li>\n<li>Get-VMHostService<\/li>\n<li>Set-VMHostService<\/li>\n<li>Get-VmhostFirewallException<\/li>\n<li>Restart-VMHostService<\/li>\n<\/ul>\n<p>Get a list of NTP servers on a host.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nGet-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot;\r\n<\/pre>\n<p>To remove a specific NTP server from a host NTP server list.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nRemove-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; -NtpServer '127.127.1.0' -Confirm:$false\r\n<\/pre>\n<p>To remove all NTP servers on a hosts NTP server list.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$arrNTPList = Get-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot;\r\nRemove-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; -NtpServer $arrNTPList -Confirm:$false\r\n<\/pre>\n<p>To add a single NTP server to a hosts NTP server list.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nAdd-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; -NtpServer &quot;dk.pool.ntp.org&quot; -Confirm:$false\r\n<\/pre>\n<p>To add a a list of NTP servers to a hosts NTP server list.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$arrNTPServers = (&quot;dk.pool.ntp.org&quot;,&quot;de.pool.ntp.org&quot;,&quot;us.pool.ntp.org&quot;)\r\nAdd-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; -NtpServer $arrNTPServers -Confirm:$false\r\n<\/pre>\n<p>To set the NTP deamon (service) to start automatic.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nSet-VMHostService -HostService (Get-VMHostservice -VMHost (Get-VMHost &quot;esx01.lab.local&quot;) | Where-Object {$_.key -eq &quot;ntpd&quot;}) -Policy &quot;Automatic&quot;\r\n<\/pre>\n<p>Open firewall to allow the NTP deamon to communicate with the NTP server.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nGet-VmhostFirewallException -VMHost &quot;esx01.lab.local&quot; -Name &quot;NTP Client&quot; | Set-VMHostFirewallException -enabled:$true\r\n<\/pre>\n<p>To restart the NTP deamon (service) after you have configured it &#8211; without restarting the host.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$ntpd = Get-VMHostService -VMHost &quot;esx01.lab.local&quot; | where {$_.Key -eq 'ntpd'}\r\nRestart-VMHostService $ntpd -Confirm:$false\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you want to configure a hosts NTP server list through PowerCLI you have a few cmdlet at your disposal. Get-VMHostNtpServer Remove-VMHostNtpServer Add-VMHostNtpServer Get-VMHostService Set-VMHostService Get-VmhostFirewallException Restart-VMHostService Get a list of NTP servers on a host. Get-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; To remove a specific NTP server from a host NTP server list. Remove-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; -NtpServer\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.amikkelsen.com\/?p=458\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[234,236,239,233,237,232,330,235,238],"class_list":["post-458","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-add-vmhostntpserver","tag-add-vmhostservice","tag-get-vmhostfirewallexception","tag-get-vmhostntpserver","tag-get-vmhostservice","tag-ntp","tag-powershell","tag-remove-vmhostntpserver","tag-restart-vmhostservice"],"_links":{"self":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts\/458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=458"}],"version-history":[{"count":13,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts\/458\/revisions"}],"predecessor-version":[{"id":471,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts\/458\/revisions\/471"}],"wp:attachment":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}