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 (auto-poweron.sh) which is placed in a vmfs volume.

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

[crayon lang=”shell”]
vmname=”testvm”
vmid=$(vim-cmd vmsvc/getallvms | grep “$vmname” | awk ‘{print $1}’)
stat1=$(vim-cmd vmsvc/power.getstate “$vmid” | grep “off”)
if [ “$stat1” == “Powered off” ]
then
vim-cmd vmsvc/power.on “$vmid”
fi
[/crayon]

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

Upgrade to VMware vShield Endpoint1.0U3 using CLI

Gallery

In recent past, one of the hosts in Data-centre PSODed with the following Stack Trace. <snip> VMware ESX 4.1.0 [Releasebuild-502767 X86_64] #PF Exception 14 in world 4217:helperNN-N IP 0xnnnnnnnnnnnn addr 0xd8 …. 0xnnnnnnnnnnnn:[0xnnnnnnnnnnnn]VFileFilterReconnectWork@esx:nover+0x67 0xnnnnnnnnnnnn:[0xnnnnnnnnnnnn]WorkInvoke@vmkernel:nover+0x2b 0xnnnnnnnnnnnn:[0xnnnnnnnnnnnn]helpFunc@vmkernel:nover+0x53e </snip> As mentioned in the KB 2009452 … Continue reading