Mastering the use of PowerShell and the vSphere PowerCLI to manage your virtual machines will help you get more...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
done in less time, and with fewer errors. In this article we reference several useful tips for getting started with the vSphere PowerCLi and PowerShell and point you towards some very useful scripts written by VMware administrators.
An introduction to vSphere PowerCLI and PowerShell
First things first. The vSphere PowerCLI was formerly known as the VMware Infrastructure Toolkit or VI Toolkit, so if PowerCLI was a foreign term to you, blame the VMware marketers. Why should you care to learn about PowerCLI and PowerShell? Here are a few reasons. First, repeated tasks performed manually introduces a higher chance for error. Second, the computer is faster than you are; and lastly, if the technology is readily available to you, why not use it?
So how does PowerShell, a Windows tool, work with VMware?
The vSphere PowerCLI, allows you to use PowerShell to communicate with the vSphere advanced programming interface (API). To use it, you'll need to have PowerShell installed on your workstation, so if you're just starting the first article you'll want to reference in this guide to vSphere PowerCLI and PowerShell commands for VMware is the one that will walk you through installing and using Windows PowerShell.
Or, if you're already familiar with PowerShell and have it on your machine, you can jump ahead to the second part of that series. In part two, you'll learn how to install and use Quest's PowerGUI, which is geared towards those who shy away from traditional scripting and prefer to use a graphical user interface (GUI), but also includes a script editor. PowerGUI allows you to choose from a variety of options in a point-and-click manner, at which point PowerGUI does the heavy lifting (scripting) for you and returns the results of the desired command. You'll also learn what the actual PowerShell commands are by making your selections within the PowerGUI.
Putting VMware virtual machines to work with PowerShell commands
If you're already familiar with the PowerCLI and would prefer not to use the PowerGUI, reading our article on using Get-VM to work with virtual machines may be your preferred starting point. This article goes over the details of scripting and the various properties that are important to understand if you desire to understand -- and one day tweak and create your own -- PowerShell scripts for VMware.
In another SearchVMware.com article, we share five simple PowerCLI PowerShell scripts that are nonetheless useful for the everyday tasks of a VMware administrator. You'll learn how to power-on a virtual machine, update VMware Tools, find out which VMs are on a local disk, configure the NTP time server for hosts, and more.
Putting it all together: Scripting advanced VMware tasks
Once you're comfortable with using PowerCLI or the PowerGUI to leverage PowerShell and batch-manage your virtual machines, you may want to try more advanced maneuvers. It's possible to perform such advanced tasks as customizing your VMware Site Recovery Manager disaster recovery plans with the VMware PowerCLI and PowerShell scripts.
In our tip which explains how to do exactly that, you'll learn how to tell each virtual machine to reduce its memory use during the recovery process; how to search for specific virtual machines and tell just those machines to reduce their memory consumption; and/or how to reduce memory use by a certain factor instead of limit it to a set amount.
One of the most useful things about PowerCLI and PowerShells scripts for VMware is that many administrators who have created useful codes share them on their blogs or webpages for you to use. The SearchVMware.com editorial staff collected what we think are some of the most useful VMware PowerShell scripts on the Web and composited them for you in one location. Here, you'll find scripts that take an inventory of your virtual infrastructure and have it sent to your inbox via email every morning; enable you to find out who created what virtual machine; find out how many ports a virtual switch uses before a VMotion, preventing a vNIC disconnect; and get colorful reports sent into Microsoft Word that detail what's going on in your VMware environment – helpful for managers, or anyone else desiring to know what's happening in your VMware environment.
Hannah Drake is the site editor of SearchVMware.com. She graduated in 2006 from the University of Massachusetts Amherst magna cum laude as a double major in journalism and english. Hannah joined TechTarget as an editorial intern in 2005 for a year before joining full-time after graduation, and has worked on both SearchDataCenter.com and SearchServerVirtualization.com for TechTarget before helping to launch and eventually becoming the editor of SearchVMware.com. She can be reached at firstname.lastname@example.org.