Best Practices


Checking and Setting Time with vSphere PowerCLI and vWire

by Steve  | June 19th, 2009

I posted earlier in the week that I was going to present some scripts that are using one of the new cmdlets from the vSphere PowerCLI.  The scripts today are for getting and setting time information on the ESX hosts. If you have installed vWire then you can download the action here.

Inside this xml bundle you will find three scripts to work with this time.  There is one script to check and another script to set the time server settings on the VMware ESX server. Both these scripts are considered and deployed as a host based action. There is one more script that sets the time server settings from a Cluster level in vWire.  If you run the cluster based time script it will set the time on all the servers in the cluster it was run against.

Let’s take a look at the code..

Foreach ($h in $input)
{
Add-VmHostNtpServer -NtpServer “time1.timserver.com”,”time2.timeserver” -VMhost $h
}

As can see there is really not much to the code and you have to really love PowerShell for what you can do with your environment. 

 

Have a good weekend and happy scripting!

 

Steve


Tags , , , , ,

This entry was posted on Friday, June 19th, 2009 at 11:42 am and is filed under Virtual Tech. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Add a Comment

x

Subscribe to The Virtual Black Hole RSS Feed Email Notification

Enter your email address:

Delivered by FeedBurner