ESXi bash script to automate Power ON VM if its Powered OFF

This script with the help of crontab will enable ESXi 5.1 to poll the VM state every hour to check if it is ON and if not power it ON.

1. SSH to the host.
2. Copy and paste the following content to the shell script ( which is placed in a vmfs volume.

Eg :-
Having enabled ssh access to your ESXi server, ssh in as root.
~ #vi /vmfs/volumes/datastore1/

3. Replace ‘testvm’ with the appropriate vmName.
Continue reading

PowerCLI script to list VMFS,RDM and Free LUNs in a cluster

Its always a time consuming job to find out the LUN is FREE, RDM or VMFS. The following script will help to get the details of LUNs from hosts in a cluster and will tell us the LUN is VMFS, RDM or FREE.

If the LUN is an RDM, we can see on which VM RDM is mapped. And if the LUN has VMFS volume, the datastore name will be displayed. Also the script provides the details like LUN number, Capacity and naa id (Canonical Name).

The CSV file that is produced by the script looks like this. In this example cluster has four hosts (esx1,esx2,esx3 and esx4), four LUNs (0,1,2 and 13) are shared among them.


You can see there are four values for TYPE.

1. VMFS :- VMFS volume (datastore)
Continue reading

VM Inventory as e-mail with hyperlinks to vCenter Web UI and VM console

This post is to publish the enhanced version of the script PowerCLI sccript for exporting VM details to HTML. This version has the following features added.

1. Report will be sent as e-mail in HTML format.
2. Added Hyperlink to the vCenter Web Client to login.
3. Each VM will have the Hyperlink to the corresponding VM Console.

The output that is produced by the script looks like this


1. Hyperlinks will work only on vCenters with vSphere version 5.1 or above.
Continue reading

Trigger e-mail when user RDP to vCenter server.

We have strict logon policy on VMware Management servers like vCenter, View connection brokers etc. We have been looking for a solution to get alerts when someone RDP to the Management Servers (all are Windows 2008/2012).

Combination of Windows Task Scheduler and PowerShell script did the tick.

1. The following Powershell script “Get-RDPUser.ps1” will get the last terminal server (RDP) session details and send e-mail to the team in HTML table format.

Continue reading

PowerCLI one liner for finding HBA model, WWPN and driver details.

Its a one liner for getting HBA details of all hosts connected to a vCenter Server.

VMware Cloud Cred. Its real fun!!

Cloud Cred is a professional peer-based ranking system that makes it easy to identify the most credible, up-to-date and follow-worthy experts on cloud computing. Participants earn points for activities that demonstrate cloud knowledge, which is expressed as a numerical Cloud Cred score and a level of mastery. Achieving a certain Cloud Cred score also unlocks various rewards and incentives.
Continue reading

PowerCLI to see the windows guest IPv4 Network Details.

Its a tiny script to find the IP address, DNS and WINS server of a windows VM. Its an example for invoking guest scripts through PowerCLI.

Save few seconds when you connect to the View desktop.

By adding few parameters to View Client shortcut we can save some time daily while connecting to the desktop. Follow the below mentioned steps if the domain login credential for View desktop and local machine are same.

1. Right click the View Client shortcut and select Properties.
2. If the View client installation is done at the default directory then the Target will be like this.

“C:\Program Files\VMware\VMware View\Client\bin\wswc.exe”

Append parameters  -loginascurrentuser, -server, -desktopname  and -interactive to Target.
Continue reading

PowerCLI one-liner to find the VM which has Raw access to a particular LUN

We had a requirement to find the VM with RDM which holds specific naa ID. The following one-liner made our task easy.