VMware Cloud Community
CarenectionMatt
Contributor
Contributor
Jump to solution

Remove-VMHostNtpServer not removing anything.

I'm trying to PowerCLI up our configuration for some standalone (non-clustered) ESXi hosts, and I'm having an issue where Remove-VMHostNtpServer doesn't actually remove anything.

After importing the PowerCLI modules and connecting to the ESXi host I want to reconfigure, I run the "Remove-VMHostNtpServer" cmdlet with one of the ntp servers I want to remove, see the "update time config" task return a "completed successfully" result in the webclient... but the old NTP servers are not removed, even after a long wait (~30 mins), and restarting the ntp daemon:

ESXINTP.png

PowerShell console output, for better readability:

PS C:\WINDOWS\system32> Get-VMHostNtpServer -VMHost $ESXiServer -Server $ESXiServer;

pool.ntp.org

us.pool.ntp.org

PS C:\WINDOWS\system32> Remove-VMHostNtpServer -NtpServer 'pool.ntp.org' -VMHost $ESXiServer -Server $ESXiServer -Confirm:$false;

PS C:\WINDOWS\system32> Get-VMHostNtpServer -VMHost $ESXiServer -Server $ESXiServer;

pool.ntp.org

us.pool.ntp.org

Anyone have any idea about what's going wrong, how to correct it, or even troubleshoot it?

I'm running this from PowerShell (ISE) 5.1.16299.431, PowerCLI 10.1.0.8403314 (Though, I'd had the same non-results on PowerCLI 6.5.0 something, and upgraded in hopes of fixing it) against an ESXi host running ESXi 6.5.0 Update 2 (Build 8294253).

1 Solution

Accepted Solutions
CarenectionMatt
Contributor
Contributor
Jump to solution

It's a known issue, and according to VMware support, is expected to be fixed in PowerCLI 10.2, whenever that's out.

VMware PowerCLI Release Notes

Remove-VMHostNtpServer
Remove-VMHostNtpServer might not remove NTP servers from the NTP server list depending on the server version.

Awful lot of pretty egregious known issues in there.  Like paying to be a beta tester for VMware.  >:/

View solution in original post

0 Kudos
12 Replies
LucD
Leadership
Leadership
Jump to solution

Do you have a full license on that ESXi node or a free license?

In case you are using a free license, you only have read access (the Get- cmdlets)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
CarenectionMatt
Contributor
Contributor
Jump to solution

As a matter of fact, I do.  I was going to add the license key at a later point.

Strangely, I've been able to rename the host, set the password, ADD NTP servers, a few other things on the evaluation license.  Ugh.  Well, thanks, I'll give that a try when I'm back in the office tomorrow.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

No, I didn't mean an evaluation license but a free license.

With an evaluation license it should work.

I'm curious to know if you can remove the NTP server via the Host Client?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
CarenectionMatt
Contributor
Contributor
Jump to solution

It was on an evaluation license.  I applied a standard vSphere 6 license to the host (via PowerCLI), and still have the same issue.

I can remove the NTP servers through the webclient, yes, but not PowerCLI.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Are you connected to a vCenter or directly to the ESXi host?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
GHDijker
Contributor
Contributor
Jump to solution

Same here with latest PowerCLI, just removed it from the incorrect host using the Web ui. PowerCLI could add but did not remove, and quit silent.....

0 Kudos
CarenectionMatt
Contributor
Contributor
Jump to solution

It's a known issue, and according to VMware support, is expected to be fixed in PowerCLI 10.2, whenever that's out.

VMware PowerCLI Release Notes

Remove-VMHostNtpServer
Remove-VMHostNtpServer might not remove NTP servers from the NTP server list depending on the server version.

Awful lot of pretty egregious known issues in there.  Like paying to be a beta tester for VMware.  >:/

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I think you don't pay anything for PowerCLI :smileygrin:


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
andiwe79
Enthusiast
Enthusiast
Jump to solution

Just ran into this issue with PowerCLI 11.0 again and solved this by not using the Remove-VMHostNtpServer command but by updating the config itself by powercli.

Any NtpServer not in $config will be removed.

$config = New-Object VMware.Vim.HostDateTimeConfig

$config.NtpConfig = New-Object VMware.Vim.HostNtpConfig

$config.NtpConfig.Server = New-Object String[] (2)

$config.NtpConfig.Server[0] = '10.1.1.1'

$config.NtpConfig.Server[1] = '10.2.2.2'

$config.NtpConfig.ConfigFile = New-Object String[] (0)

$config.TimeZone = 'UTC'

$vmhosts = Get-Cluster | Get-VMhost

foreach ($vmhost in $vmhosts) {

     $view = get-view $vmhost

     $_this = Get-View $view.ConfigManager.DateTimeSystem

     $_this.UpdateDateTimeConfig($config)

     Restart-VMHostService -HostService ($vmhost | Get-VMHostService | Where {$_.Key -eq “ntpd”}) -Confirm:$false

}

Best regards

Andi

swinster
Enthusiast
Enthusiast
Jump to solution

Still in v11.1 Smiley Sad

user29876561
Contributor
Contributor
Jump to solution

Glad to hear that I am not the only one seeing this in the newest version.

For version reference:

PS C:\> Get-Module VMware* -ListAvailable | Select-Object Version,Name | Format-Table -AutoSize

Version         Name

-------         ----

6.7.0.11233116  VMware.DeployAutomation

6.7.0.8250345   VMware.DeployAutomation

6.7.0.11233116  VMware.ImageBuilder

6.7.0.8250345   VMware.ImageBuilder

11.1.0.11289667 VMware.PowerCLI

11.0.0.10380590 VMware.PowerCLI

6.7.0.10334489  VMware.Vim

11.0.0.10335701 VMware.VimAutomation.Cis.Core

11.0.0.10379994 VMware.VimAutomation.Cloud

11.0.0.10334497 VMware.VimAutomation.Common

11.0.0.10336080 VMware.VimAutomation.Core

7.6.0.10230451  VMware.VimAutomation.HorizonView

10.0.0.7893904  VMware.VimAutomation.License

11.0.0.10364044 VMware.VimAutomation.Nsxt

11.0.0.10334495 VMware.VimAutomation.Sdk

11.0.0.10380515 VMware.VimAutomation.Security

11.1.0.11289292 VMware.VimAutomation.Srm

10.0.0.7893900  VMware.VimAutomation.Srm

11.1.0.11273342 VMware.VimAutomation.Storage

11.0.0.10380343 VMware.VimAutomation.Storage

1.3.0.0         VMware.VimAutomation.StorageUtility

11.0.0.10336077 VMware.VimAutomation.Vds

11.0.0.10336076 VMware.VimAutomation.Vmc

10.0.0.7893921  VMware.VimAutomation.vROps

6.5.1.7862888   VMware.VumAutomation

0 Kudos
WhiteCase
Contributor
Contributor
Jump to solution

@Andi,

thanks for the workaround, working perfectly! Just spent a few hours on this issue before I found your post Smiley Happy

0 Kudos