Customisation: Lesson 1 – Time Source

I thought I would help people learn the VI Toolkit whilst also creating a nice script which you can customise to your own environment, hopefully this is a script that will save you time in the future.

The script we are going to build together in step by step instructions is a Customisation script.

You have built your host and now have to go through the configuration and tweaks of all the after-build areas, you have to make sure that these are setup the same on each host so that things like VMotion and DRS work so what better than a script to help us limit the amount of mistakes when typing names or missing steps.

Imagine you have built your host, what customisations do you apply to it ? Please let me know and I will make sure I cover it in these lessons so that people can include it in there build script and save everyone time.  Please leave a comment with your suggestions.

Lesson 1 – setting the NTP server.

We all know time is important, without time things stop working, more than a couple of minutes out can cause major issues so the first thing we do just after building our host is to setup the NTP server.


You could log into Virtual Center, click on the new host and select the configuration, Time Configuration selection remove the default setting for ‘’ and add your own time source but we don’t want to do that because we want to script it.

With the VI Toolkit we are given Remove-VMHostNtpServer and Add-VMHostNtpServer so lets make use of these cmdlets to remove the default NTP server and add our own one in.


First lets store our server name in a variable:

$VMHost =

Now we have this stored lets remove the default NTP Server from that host:

Remove-VMHostNtpServer -VMHost $VMHost -NtpServer

After this we can add our new NTP Server:

Add-VMHostNtpServer -VMHost $VMHost -NtpServer




So we now have a ntp server added, wow that didn’t save much time, but wait till we build this script up to add in our networks, configure precise settings etc, then we will have an extra 30 mins lunch break whilst our script does the work !


Our Script So Far:


Connect-VIServer myviserver

$VMHost =

Remove-VMHostNtpServer -VMHost $VMHost -NtpServer

Add-VMHostNtpServer -VMHost $VMHost -NtpServer

11 thoughts on “Customisation: Lesson 1 – Time Source

  1. Raja.M

    Hi i have problem in out environment , time sync issue EVEN ID 50 was creating all VM due ,

  2. Umar

    Great Great Great I came across this website and I must say Alan you are doing a wonderful job. I am new in scripting and this is helping me a lot.

    I am using your vCheck Daily which is amazing as well I was using Rvtool or manualy powercli but your script does the job automatically which is great.

    Thanks for all your help and support :).


  3. Virtu-Al

    Thanks Mario, I will definitely include these, hadn’t thought about service console memory, good one !

  4. Mario Vinet

    If I may also add, configure Vswitch would be nice. Service Console Memory, Enable in Security Profiles a check box (like NIS client).

    Cody and Virtu-Al I have to agrre with Virtu-Al I’m completely ignorant in Vi-Toolkit/Powershell so the more it’s basic the better!

  5. Virtu-Al


    Thanks for the suggestion, its a great Idea but I want to introduce people to these things slow, this is a wonderful more advanced way to configure the hosts but perhaps we will leave this until we have covered the basics 🙂 Thanks for our input.

  6. Cody Bunch

    so rather than $VMHost = “”, we could do a few things, optimally would be take input from the pipeline into that variable:

    begin {
    $ntpserver = ‘’

    process {
    if ( $_ -isnot [VMware.VimAutomation.Client20.VMHostImpl] ) { continue }
    Remove-VMHostNtpServer -VMHost $_ -NtpServer ‘‘
    Add-VMHostNtpServer -VMHost $_ -NtpServer $ntpserver

    We can then add more things into the process block as we grow the script. This would allow us to better target the hosts that we need to make the changes on.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.