Geaux Virtual

Helping virtualize the datacenter…

Setting time on ESXi hosts through PowerCLI

with one comment

So you go and build your new ESXi hosts, set NTP, but notice your time is still off. Did you know you can set your ESXi host time through PowerCLI?

After connecting to a host, you can set the time with the following commands. Always make sure you use UTC time when setting the time on your host as ESXi does not use timezones.

$t = Get-Date
$dst = Get-VMHost | %{ Get-View $_.ExtensionData.ConfigManager.DateTimeSystem }
$dst.UpdateDateTime((Get-Date($t.ToUniversalTime()) -format u))

And there you go. Now your ESXi hosts will have the same time as the machine you ran your script on, so just make sure that machine has the correct time.

And on why I have not blogged in a while, well that is another blog post.

Advertisement

Written by jguidroz

November 29, 2011 at 4:19 pm

Posted in Scripting, VMware

One Response

Subscribe to comments with RSS.

  1. ## Setting time on many ESXi hosts through PowerCLI
    Get-VMHost | Where-Object {
    $t = Get-Date
    $dst = $_ | %{ Get-View $_.ExtensionData.ConfigManager.DateTimeSystem }
    $dst.UpdateDateTime((Get-Date($t.ToUniversalTime()) -format u))
    }

    Oscar Madrigal

    April 2, 2012 at 10:16 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: