ESX(i) NTP Server settings: PowerCLI

I read a great post by Roger Lund today that discussed timekeeping in VMware virtual machines. That got me thinking, “How would this be handled with PowerCLI?” A blog post was born. ๐Ÿ™‚

The first thing that I did was to check the NTP server settings on all of my VMware servers.

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

Pretty straightforward. Retrieve all of the VMhosts within vCenter, create an array to hold the results, then begin cycling thru all of the hosts and add their hostnames and NTP server settings into the results array. The results come out looking like this:

Name                        NTPServer
----                        ---------
esx01a.domain.com           domain.com
esx01b.domain.com           domain.com
esx01c.domain.com
esx01d.domain.com           domain.com

So, what do you do if you want to change the host that is missing the NTP server settings?

Get-VMHost -Name esx01c.domain.com | Add-VmHostNtpServer -NtpServer "domain.com"
Get-VMHostService esx01c.domain.com | Where-Object {$_.key -eq "ntpd"} | Restart-VMHostService -Confirm:$false 

There you have it. Isn’t PowerCLI great? ๐Ÿ™‚

Comments

  1. I am a librarian. So many people asked to borrow Dan Brown’s Da Vinci Code that I eventually read it myself to see what the fuss was about. Absolute junk! Maybe suitable for a 10 year old child but not adult reading. I have not wasted time reading any other books by Dan Brown. Having read the reviews posted here, I note that other people are also (finally) beginning to realise that this author has no talent and produces work of insultingly low quality.

  2. Some of my most well-received, commented on posts, flash fiction and poems are the ones that come straight from the soul, the ones that have me second-guess myself and questions if I should hit “publish” or bury them…Estrella Azul recently posted..

  3. Happy Birthday to your sweet little girl. That is so cool you get to pick your own yellos flowers when your out and about. It's only leaves on this side of the world. Loved it all!

  4. July 3, 2008 – 5:17 am Great article, Matt! I am tempeted print it out and give it to all those clients that argue with me that what they currently have is just fine. You made fantastic points very fast and in easy-to-understand terms for businesses.

  5. Ooh! I liked their banter too. I loved it when Stefan had that sweet voice and told Klaus he could pick who they’d kill. Hilarious. Yeah, that would have been more believable; if it was just a shy smile. Though, I can’t help but hope that Delena would just happen already. Lol. I’m sure there’s fanfiction already for that. Haha! That would make a could title “Switching Salvatores” . . . You should remember, Katherine is ALWAYS up to something. P.S. Don’t forget your Damon hug

  6. Thanks Karen. I love highlighters but I also love peachy blushes That’s a tough one and I definitely shouldn’t get both. Btw, have you seen the new Chanel highlighting powder? It’s sooo gorgeous!!!

  7. you should add:
    foreach
    if empty (or )
    add-vmhostntp ….

  8. in PowerCLI 4.1 i get
    Get-VMHostNtpServer : 11/18/2010 8:59:45 PM Get-VMHostNtpServer Index was outside the bounds of the array.
    At line:4 char:40
    + $detail.NTPServer = Get-VMHostNtpServer <<<< -vmhost $vmhost
    + CategoryInfo : NotSpecified: (:) [Get-VMHostNtpServer], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetVMHostNtpServer

    any ideas what im doing wrong?

Trackbacks

  1. new John lewis store cardiff

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  2. babies r us says:

    babies r us

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  3. electrical wholesale jobs west yorkshire

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  4. Furniture For Sale In Atlanta

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  5. anchor says:

    anchor

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  6. electrical wholesale supplies bangor

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  7. http://www.gravitybattle.com/

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  8. christiantourseurope.com

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  9. Online shopping shoes us

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  10. http://www.lunyizhijia.com

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  11. online score card of aieee 2012

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  12. http://internetsupervision.com

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  13. St1688.com says:

    St1688.com

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  14. discount furniture warehouse san diego

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  15. Maplin electronics.co.uk

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  16. john lewis partnership card log

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  17. similar site says:

    similar site

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  18. indian jewelry online store in usa

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  19. http://www.Alkrsan.net

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  20. electricals direct london

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  21. electrical supplies birmingham al

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  22. john lewis sale 2013 dates

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  23. Ondline.Net says:

    Ondline.Net

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

  24. anchor electricals price list india

    ESX(i) NTP Server settings: PowerCLI โ€” DAMIAN KARLSON

Speak Your Mind

*