Saturday, September 16, 2017

VMware ESXi Host Cluster Build Version Comparison

Did you upgrade all the ESXi Hosts in a Cluster? How was the experience? Now you must be planning to upgrade VMTools and Hardware Version. It is recommended to keep every node identical in a Cluster even if it is a vCenter Cluster with amazing flexibility. Would you like to validate if somehow any of Cluster Host is on different patch level (Build Version). This script is the solution to given problem at any given time. It will give you the report in your inbox with HTML as body and CSV file as attachment. Give it shot and share your experience. Looking forward to hear from you all.

VMTools and Hardware Version Report

You may find even one liners with PowerCLI to find out the VM Tools status and spend some more logic and you can run it on multiple vCenter Servers too. What about the VM Hardware Version? Here is the script which will help you generate a report of every VM's VM Tools and Hardware Version status from multiple vCenter Servers. Hope you aren't using less than VMware vSphere 4.x otherwise it will provide you the desired output. From VMware vSphere 4.x to 6.5 everything is tested with this so test it. Looking forward to hear from you.

All vCenter Server's Alarms

vCenter Server alarms are good but consolidate in a report from multiple vCenter Servers is even better. This script is quick and easy to have all the vCenter Servers alarms in your inbox with adequate information. Keep your VMware Infrastructure green and minimize the time taken by this script. Looking forward to hear from you all.

Powered Off VMs

Have yourself email with all the Powered Off in your environment even if they are in different vCenter Servers. Best thing, you will get the information of user account used to Poweroff and how old is this powered off VM. Reclaim space in Datastore and save something for employer. Looking forward to hear from you guys.

Friday, September 2, 2016

VMware Virtual Machine Disk Management

Finally wait is over and here is the interactive PowerCLI scipt to increase any hard disk (VMDK) of Virtual Machine online w/o login into vCenter Server or Windows Guest VM.

I have tested it on Powershell 5.0, PowerCli 6.3, vSphere 6.0, Windows 2003, Windows 2008, Windows 2012.

After executing this script, there will be a popup asking for vCenter Credetials and Windows Guest Credentials (obviously with enough permission to increase disk/s).

Combo box will automatically populate all the VMs from vCenter inventory as soon as you click on login so please be patience after pressing Login button.

You can select the any of disk populated in Grid View row and put the increased size of the disk (it will choose to ignore if you put less than the existing size of disk ;) ). It will help you to figure out the relation of VMDK and Drive han?

And voilla, disk increased in VM configuration and within guest system to use.

Note: you need to login into Windows 2003 VM to increase the C Drive (boot partition). In other words, it will increase the disk size of System Partition in VM Configuration but leave it to you increase it within Windows.

Tuesday, August 16, 2016

Snapshot Solution GUI

Hello Guys

In continuation of my first script, I am again writing another script to play around with VMware Virtual Machine's Snapshot but with a GUI and Take/Commit(Remove) snapshot functionality.

There are many scripts available on Internet to report/manage VM's Snapshot automatically so what does this has to offer. Here couple of things which can be taken care with the help of this GUI Script.

1.    Connect the VMware vCenter Server w/o VI Client or Webclient
2.    Single console to list most of the required information
3.    Highlights VM's Name in case of low disk space (Yellow if less than 50Gig & Red if less than 25Gig free in the affected Datastore). It helps to identify the Datastores with critical status.
4.    Anyone can use this after single session (helps to offload the task w/o risk)
5.    Not only Snapshots but VM's information is also available including RDM
6.    Virtual Machine button populates information about each registered VM in columns VMName, Host, Cluster, PowerState, ToolsStatus, Snapshots, RDMs, MemoryMB, ProvisionedGB, DatastoreName, DatastoreCapacity, DatastoreFreeSpace, OS
7.    Snapshot button populates information about all the Snapshots of registered VM in columns VMName, SnapshotName, SizeInGB, CreatedTime, AgeInDays, Datastore, DatastoreCapacity, DatastoreFreeSpace, OperatingSystem, CreatedByLogin
8.    Datastore information is available even if VM Configuration (VMX) or Disks are attached from multiple Datastores.
9.    Buttons get disable and enable to avoid confusion & mistakes
10.    Manual credentials and Use Windows Login Credentials, both the options are available
11.    Status bar reflects the status of the Commands or Warning
12.    Use Alt+<Highlighted Letter> if you wanna avoid using Mouse

1.    .Net Framework 4.5
2.    Powershell 5.0 (Not tested on earlier versions)
3.    PowerCLI 6.0 U3 (Not tested on earlier versions)
4.    vCenter connectivity (required ports shouldn't blocked)

Give it a shot and looking forward to hear from you


Wednesday, August 10, 2016

VM Snapshot with Datastore Information

VM Snapshot with Datastore Information

Hello Guys

The actual credit goes to couple of guys here who gave me raw of this script.
This is the first script I wrote and improved continuously over the period of time. Every week I saw the script output and seek another opportunity to improve.

Initially this script should be letting me know about the active snapshots in the environment. Later on it was pointed out that Datastore information is missing which is technically the deciding factor to keep or commit the snapshot. Whereas VMware recommends to keep maximum 3 Snapshots for 3 days but he knew this too that infra doesn't run by with recommendations. Anyway, as we all know if datastore free space is anywhere near ZERO, we are doomed so its not about the age. Point accepted and added it as another table in output (because couldn't figure out a way to keep it in single table - dumb me), which addressed the concern but not in a good way. Or should I say difficult to read and understand? To understand the output, you need to review two tables and co-relate them to find out the affected Snapshot and Datastore. And saw another bug as "system.object" instead of Datastore information in few of the cells against couple of VMs. BOOM!

First thing first, I spend some more time on this and fixed two tables output. Though it is providing Datastore information in the Snapshot table (Datastore Table gone now) but next bug needed my attention too. Reason, this was actually happening against the VM's VMDKs connected from multiple Datastore. Script was not ready to handle to such output of any variable. Actually this was the most tricky part in the script which ate most of my time after fixing whole info in single table. At last, I was able to clean this from my plate too.

Then I used this script for 6 months and felt kinda satisfied with the maturity of this script. Practically I was busy in other stuff and couldn't focus on this to find out another improvement. One day I saw an output of more than 100 active Snapshots so you can imagine the length of the email/table. Now it was very irritating to find out the Datastore running with risk.

"Necessity is the mother of invention" - English-language proverb

Eventually I got something I need "highlight the critical". I started working on this again an implemented it. Now script out was appearing exactly like the Sample Output shown below. It highlights the VMName as Red for less than or equals to 25Gig or Yellow for less than or equals to 50Gig Datastore Free Space. Even if there are multiple datastore involved, VMName will be highlighted in case of any datastore having less free space.

Cool? nah! there are so many things you can do with this script and use the ideas used in this script to create new scripts.

VMware is cool but PowerCLI is like cherry on the top.

Anyway, you can use this script to have an email of all the active Snapshots of VMs as body (no attachment). Do remember to personalize vCenter, SMTP Server, Email etc. before running the script. It is perfectly ready to run as Schedule Task without storing your password in plain text (Security is not breached). Hope you like it and feel free to share and like it.

Sample Output