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 ‘127.127.1.0’ 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 = “myhost1.mycompany.com“
Now we have this stored lets remove the default NTP Server from that host:
Remove-VMHostNtpServer -VMHost $VMHost -NtpServer ‘127.127.1.0‘
After this we can add our new NTP Server:
Add-VMHostNtpServer -VMHost $VMHost -NtpServer ‘ntp.mycompany.com‘
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 = “myhost1.mycompany.com“
Remove-VMHostNtpServer -VMHost $VMHost -NtpServer ‘127.127.1.0‘
Add-VMHostNtpServer -VMHost $VMHost -NtpServer ‘ntp.mycompany.com‘
Hi i have problem in out environment , time sync issue EVEN ID 50 was creating all VM due ,
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 :).
Regards
Umar
Thanks Mario, I will definitely include these, hadn’t thought about service console memory, good one !
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!
Cody,
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.
Great idea Alan.
There are some good posts with suggestions for configuring an ESX in the VITK community.
Have, for example, a look at http://communities-origin.vmware.com/message/1040385#1040385 and http://communities-origin.vmware.com/docs/DOC-8170.
so rather than $VMHost = “myhost.mycompany.com”, we could do a few things, optimally would be take input from the pipeline into that variable:
—
begin {
$ntpserver = ‘pool.ntp.org’
}
process {
if ( $_ -isnot [VMware.VimAutomation.Client20.VMHostImpl] ) { continue }
Remove-VMHostNtpServer -VMHost $_ -NtpServer ‘127.127.1.0‘
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.
@Duncan
That’s a good one
active/passive setup for VMkernel and Service Console
Thanks Duncan, I will make sure I cover this after the basics
Disk.UseDeviceReset = 0
So people know how to set an advanced setting…