vSphere 4.1 guest vm shutdown script

Posted on 2011-05-11
Last Modified: 2012-05-11
I have a stand-alone ESX host running vSphere 4.1, without Virtual Center. The hosts have APC Powerchute configured to shutdown if the UPS runs low. One of the guests is on a subnet that cannot talk to the APC Network Management Card, so I cannot use PCNS. I need a script that will gracefully shut down one guest before the host shuts down. I have not done any scripting with vmware. Please indicate how to create the script and where it should be located. Should I have the APC network management card activate the script, or will the host automatically do it prior to shutting itself down?

Thanks in advance for your help.
Question by:fisher_king
    LVL 116

    Accepted Solution

    Why don't you use the Auto Shutdown Guests before Host Shutdown?

    So when the ESX server gets the request to shutdown, it will delay and shutdown the Guests, before it turns off.

    Otherwise scripts Have a look here

    this perl script could be used

    You will need a few additionals

    I would recommend using the following, also VMware recommends the use of PowerCLI, which is PowerShell interface with vSphere-specific additions.

    One of the simplest PowerCLI examples, and something which is actually extremely useful on its own, is the Get-VM cmdlet. Which lists VMs.

    PowerCLI can be a bit overwhelming to use,  But it can be enhanced with a nice toolset and a library of preconfigured scripts to jump-start your mass changes, which is possible with PowerGUI
    LVL 40

    Assisted Solution

    I believe the Auto shutdown feature in ESX should do what you need without the need for a script, as suggested by "hanccocka". Just log into vCenter, click on the host, then click the Configuration tab. In the 'Software' box, click the Virtual Machine Startup/Shutdown link. In the upper right click Properties. Follow the remaining steps from "hanccocka's" 1st link above.

    If you do want a script, LucD (1 of *the* premier PowerCLI gurus; literally co-wrote the book on PowerCLI :) ) provides a script in the following link:

    He gives you a script for a VM, or all VMs in a cluster.

    LVL 16

    Expert Comment

    Do you have the software(scripts) from APC that installs into the vma?

    The vma is a vm appliance that runs on your host and would get the signal from the ups, then it would communicate with the host/VC to shutdown the guests.

    I will post the link to the s/w if you can't find it.

    Author Closing Comment

    Thanks for the replies. I thought that the auto shutdown was only available through Virtual Center. But I prefer this to a script.
    LVL 116

    Expert Comment

    by:Andrew Hancock (VMware vExpert / EE MVE)
    much easier than a script.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    What are VMware Tools? VMware Tools are a suite of utilities that enhances the performance of the virtual machine's guest operating system and improves management of the virtual machine. Without VMware Tools installed in your guest operating syst…
    Create your own, high-performance VM backup appliance by installing NAKIVO Backup & Replication directly onto a Synology NAS!
    This Micro Tutorial steps you through the configuration steps to configure your ESXi host Management Network settings and test the management network, ensure the host is recognized by the DNS Server, configure a new password, and the troubleshooting…
    This video shows you how to use a vSphere client to connect to your ESX host as the root user. Demonstrates the basic connection of bypassing certification set up. Demonstrates how to access the traditional view to begin managing your virtual mac…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now