Looking for a little help with configuring NTP serivces on ESX hosts. I have the following entries:
Set-VMHostService -HostService (Get-VMHostservice -VMHost (Get-VMHost $VMHost) | Where-Object {$_.key -eq "ntpd"}) -policy "automatic" # This part works and sets the service to automatic but does not enable ntp client and so does not open the firewall
Start-VMHostService -HostService (Get-VMHostservice -VMHost (Get-VMHost $VMHost) | Where-Object {$_.key -eq "ntpd"}) # This part works and starts the service
Add-VmHostNtpServer -VMHost (Get-VMHost $VMHost) -NtpServer xx.xx.xx.xx # This part fails with - Add-VmHostNtpServer : Value cannot be null. Parameter name: collection At line:1 char:20 + add-vmhostntpserver <<<< -vmhost (get-vmhost $VMHost)
I am currently unable to Enable NTP Client which will open the NTP port of the firewall nor am I able to assign the NTP servers to the ESX host via VI Toolkit. Using Powershell v2.0 and VI Toolkit 1.5
I didn't use the Add-VMHostNTPServer applet, but you can check out my NAEPS (http://communities.vmware.com/docs/DOC-8170) to see how I configured NTP, including setting the firewall to allow NTPClient. Note that you don't need to fiddle with the firewall if the host is ESXi.
Looking for a little help with configuring NTP serivces on ESX hosts. I have the following entries:
Set-VMHostService -HostService (Get-VMHostservice -VMHost (Get-VMHost $VMHost) | Where-Object {$_.key -eq "ntpd"}) -policy "automatic" # This part works and sets the service to automatic but does not enable ntp client and so does not open the firewall
Start-VMHostService -HostService (Get-VMHostservice -VMHost (Get-VMHost $VMHost) | Where-Object {$_.key -eq "ntpd"}) # This part works and starts the service
Add-VmHostNtpServer -VMHost (Get-VMHost $VMHost) -NtpServer xx.xx.xx.xx # This part fails with - Add-VmHostNtpServer : Value cannot be null. Parameter name: collection At line:1 char:20 + add-vmhostntpserver <<<< -vmhost (get-vmhost $VMHost)
I am currently unable to Enable NTP Client which will open the NTP port of the firewall nor am I able to assign the NTP servers to the ESX host via VI Toolkit. Using Powershell v2.0 and VI Toolkit 1.5
Hi Smitty,
For the firewall aspect of things, try
get-vmhostfirewallexception "NTP Client" | Set-VMHostFirewallException -enabled:$true
I was unable to reproduce the issue you have with Add-VMHostNtpServer. What version of ESX are you using? Could you connect directly to ESX and try it like this?
add-vmhostntpserver xx.xx.xx.xx.xx
and if that doesn't work, could you try point it to pool.ntp.org, which is what I was using (that worked)?
Thanks c_shanklin. After a little modification to get it to work the get-vmhostfirewallexception line also works. I can now set the ntp service to automatic, start it running, and enable ntp client. Here is the current script to do that.
$cred = Get-Credential
Connect-VIServer +-Server +$VCName +-Credential +$cred
Set-VMHostService +-HostService +(Get-VMHostservice +-VMHost +(Get-VMHost $VMHost) | Where-Object {$_.key -eq "ntpd"}) +-policy +"automatic"
Start-VMHostService +-HostService +(Get-VMHostservice +-VMHost +(Get-VMHost $VMHost) | Where-Object {$_.key -eq "ntpd"})
Get-VMHostFirewallException +-VMHost +(Get-VMHost $VMHost) +-name +$FWName | Set-VMHostFirewallException -enabled:$true
After the firewall line I have:
Add-VmHostNtpServer -VMHost (Get-VMHost $VMHost) -NtpServer xx.xx.xx.xx
and this fails with the affore mentioned error. I tried using vi toolkit prompt and manually entered the commands connecting directly with the ESX server. Add-vmhostntpserver still failed with the same error. Beings I am new to powershell I am unsure the meaning for pointing to pool.ntp.org. We are running ESX3.5 U2, VC 2.5 U2, Powershell v2.0, VI Toolkit v1.5. No ESXi as of yet.
Thanks, Smitty. One more favor if I could, could you try connecting directly to ESX and running
Add-VMHostNtpServer -NtpServer pool.ntp.org
When you're connected to ESX directly you don't need -VMHost. I'm not sure if this will make a difference or not. Also, what update of ESX are you running?
I thought I was going mad! I had never seen the Set-VMHostFirewallException cmdlet and figured I must have overlooked it, which I am prone to do. But after looking through the cmlet help, I then decided it must be an undocumented cmdlet.
Seeing VI Toolkit 1.5, suddenly it all makes sense. Some of us have to work in released environments, you know...
Apologies for wasting people's time pointing to primitive 1.0u1 techniques.
I am using ESX3.5 update 2. I connected directly to the ESX host manually and ran Add-VMHostNtpServer -NtpServer pool.ntp.org. Same error. "Value cannot be null". Not sure what value is null.
To SCampbell, no problem. I am actually using a combination of your stuff and my above stuff to do the complete NTP configuration. Yours for the time zone and currently for the NTP server config but would like to figure out why the 1.5 command is not working. It would cut out a few lines of code.
Update. I ran the command Add-VMHostNtpServer all by itself with no switches or variables and was prompted to insert the NTP servers. After inserting the NTP servers it still failed with the "value cannot be null" error. I am now leaning towards a bug.
Hi Smitty,
are there any NTP servers set on the ESX host prior to executing the cmdlet? (you can check that by executing Get-VMHostNtpServer)
Thanks,
Irina
No. To test the script I purposely went in and removed the NTP servers manually, closed the firewall settings, stopped the service, removed the time zone setting and placed the service in disabled prior to running the script. This is a test lab environment for such things. Just in case, I ran the command and it came back blank.
There is a problem with adding NTP servers when the NTP server list on the host is empty. We have logged this as a bug and we are going to address it in future. A possible workaround for now is to have at least one NTP server set before executing the cmdlet. Not sure if it will be useful for your lab environment though
Regards,
Irina
Hi all,
I'm sorry if this is a really stupid question, but I'm new to powershell and struggling a bit.
I'm trying to configure NTP and open the firewall ports. I have tried the code on this thread, but it just doesn't execute. I get "The term 'Add-VmHostNtpServer' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again." for both the Firewall exception and add ntp comands.
I assume that these are extra cmdlets that I have to activate, but I cannot find and reference as to how to do this. I am using ESX 3.5 U3, VI Toolkit 1.0 and Perl Toolkit 1.6.
Thanks in advance for any help.
Alasdair.....
Sorry folks, please ignore my previous message. I just realise that I need VI Toolkit 1.5 Beta, which I have now downloaded. My only excuse is a lack of sleep over the last couple of weeks as I've been trying to learn powershell.
Calling Starbucks, emergency cafine injection needed.....:)