Whether the task is monumental or mundane, virtualization administrators can save themselves time and aggravation by automating tasks whenever possible. In a VMware environment, one of the more notable automation tools is vSphere PowerCLI.
In the book Learning PowerCLI, Robert van den Nieuwendijk gives step-by-step examples of various tasks being executed in PowerCLI, ranging from the installation of PowerCLI to the management of licenses on several hosts to make migrations less painful.
In Chapter 1 -- available online at the Packt site -- van den Nieuwendijk explains the basics behind PowerCLI, walks you through the installation process, and details the process of connecting PowerCLI to a vCenter Server or ESXi server before you can begin using cmdlets.
In one time-saving tutorial, van den Nieuwendijk describes how to store Windows session credentials in a credential store, which lets administrators avoid having to enter credentials each time they try to connect to a vCenter or ESXi server.
PowerCLI lets administrators create detailed reports, such as a list of all the VMs or all the hosts on the server. Van den Nieuwendijk explains the specific commands you can use to customize the reports, such as narrowing down by name, notes or host VM. He digs even deeper by explaining how to use wild-card characters and more.
Chapter 1 Highlights:
Before you can do useful things with PowerCLI, you have to connect to a vCenter Server or an ESXi server. And if you are finished, it is a good practice to disconnect your session. We will discuss how to do this in the following sections.
Connecting to a server
If you are not connected to a vCenter or an ESXi server, you will get an error message if you try to run a PowerCLI cmdlet. Let's try to retrieve a list of all of your datacenters using the following command:
PowerCLI C:\> Get-Datacenter
The output of the preceding command is as follows:
Get-Datacenter : 12/19/2013 7:29:36 PM Get-Datacenter You are not currently connected to any servers. Please connect first using a Connect cmdlet.
At line:1 char:1
+ CategoryInfo : ResourceUnavailable: (:) [Get-Datacenter], ViServerConnectionException
+ FullyQualifiedErrorId :Core_BaseCmdlet_NotConnectedError,VMware.VimAutomation.
You see that this gives an error message. You first have to connect to a vCenter Server or an ESXi server using the Connect-VIServer cmdlet. If you have a vCenter Server, you only need to connect to the vCenter Server and not to the individual ESXi servers.
Dig deeper on Troubleshooting VMware products
Ryan Lanigan, Assistant Site Editor asks:
How do you use vSphere PowerCLI?
0 ResponsesJoin the Discussion