VMware vSphere PowerCLI is a command line tool that allows virtualization administrators 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:
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.
- 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.
- 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.
- 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.
- 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.
- 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.
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 firstname.lastname@example.org.