Article

Five must-have vSphere PowerCLI scripts

Keith Kessinger, Assistant Editor

VMware vSphere PowerCLI is a command line tool that allows virtualization administrators

    Requires Free Membership to View

to create scripts, which automate administrative tasks with little to no user interaction, for vSphere environments.

PowerCLI is a snapin for Microsoft PowerShell, an object-oriented scripting language and command shell found in many data center products -- such as Microsoft Windows, Exchange and SQL servers. PowerShell automates administrative tasks through the following methods:

  • The following resources provide more information on PowerCLI:

    VMware vSphere PowerCLI: Learn it, love it

    Mastering PowerCLI: Using Get-VM to work with virtual machines

    Using PowerShell and PowerCLI to work with host servers 

    Easy installations for vCenter and VMware Update Manager

  • cmdlets, which are actions or system commands;
  • scripts, which are strings of cmdlets and associated logic;
  • executables, which are standalone applications; and
  • instantiating .NET classes

With vSphere PowerCLI, IT administrators can automate almost any virtual environment task by using 165 VMware-specific cmdlets in various combinations to create scripts. Scripts are extremely useful for virtualization administration because they carry out processes without the need of a person (thus freeing up IT personnel to do other things), can be scheduled to run during off-peak times if they are resource intensive and eliminate the possibility of human error during tedious, repetitive duties.

After familiarizing yourself with PowerCLI, here are five scripts that you can't live without.

  1.  

  2. vCheck (Daily Report) V3
    By Alan Renouf
    Imagine reading a detailed report of your virtual infrastructure before finishing your morning coffee. With Alan Renouf's popular reporting script, you can have a daily summary of your virtual environment sent to your email inbox.

    In addition to listing the number of hosts, virtual machines (VMs), clusters and data stores, the new vCheck presents VM active alerts, dead SCSI logical unit numbers and much more.

     

  3. Who created that VM?
    By Alan Renouf
    Are you experiencing VM sprawl in your data center, or are you having difficulties tracking who's creating VMs? Instead of resorting to drastic measures, such as revoking admin rights, use the Who created that VM? script to solve both of these issues.

    By adding custom fields to each VM, this PowerCLI script provides data on the VM's creator and creation date in the VM's annotations. Also, you can use this script to find out how many VMs were created in a month and export that information to a spreadsheet.

     

  4. vSwitch port overview
    By Hugo Peeters
    During a migration, VMware VMotion does not check if the new host has enough ports available on the virtual switch. Complicating matters is that if there are insufficient ports, VMotion will complete a migration without alerting the user. As a result, the virtual network interface card will disconnect.

    Therefore, every vSwitch must have enough ports to accommodate the needs of VMs on other hosts that may fail over. To check how many ports each vSwitch uses, run this PowerCLI script. Then, make the proper adjustments to your virtual switches.

     

  5. Report into Microsoft Word
    By Alan Renouf
    This script not only automates the reporting process for an entire virtual environment but it also exports the data into Microsoft Word with colorful graphs and pie charts. Furthermore, this PowerCLI script is easily customizable so that you can tailor the information to meet your requirements. This script is also great for providing a comprehensive, easy-to-read report for your bosses.

     

  6. Customizing Site Recovery Manager plans
    By Mike Laverick
    For virtualization administrators, combining PowerCLI and Site Recovery Manager (SRM) provides a high level of customization during a disaster recovery scenario.

    In this tip, Mike Laverick explains how to run PowerCLI on SRM servers and presents a script that reduces the amount of RAM used by VMs during the recovery process.

 

For more on VMware vSphere PowerCLI, check out these external resources:

>vSphere PowerCLI Blog (VMware Communities blog)
>Managing VMware with PowerShell (VMware Communities FAQ)
>PowerCLI Quick Reference Guide (from virtu-al.net)

 

Keith Kessinger is the assistant editor of SearchServerVIrtualization.com and SearchVMware.com. He is responsible for editing tips, creating editorial guides and recording podcasts. Prior to joining TechTarget, he graduated from Northeastern University in 2009 with a B.A. in journalism and minors in both economics and sociology. You can reach him at kkessinger@techtarget.com.


There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: