Information Technology Reference
In-Depth Information
If you're using PowerShell version 3, you can then use the Show-Command cmdlet to get a
visual of the cmdlet and its parameters.
Also keep in mind that PowerShell provides tab completion for all cmdlets. This means that
if you type Get-VM and press Tab, PowerShell will start sorting through all of the available cmd-
lets that begin with Get-VM, starting with Get-VM and then Get-VMGuest. This is not usually the
fastest method of i nding the cmdlet you're looking for, but it certainly works when you're in a
pinch. Tab completion also works within the cmdlet. Pressing the spacebar after a cmdlet and
then pressing Tab repeatedly will cycle you through the list of parameters for which you can
specify values.
Getting Help
It doesn't matter how long you have been working with PowerShell or PowerCLI, there will
always be times when you need help. PowerShell provides a very useful cmdlet for just this
occasion, Get-Help. Get-Help can provide helpful information about cmdlets or topics within
PowerShell. Simply type the cmdlet in your console and press Enter for a breakdown of its capa-
bilities. In the context of PowerCLI, we want to show you how you can get more information
from the cmdlets you located previously using Get-VIcommand.
Once you identify the cmdlet you need, you can use Get-Help to i nd out more about it, like
the parameters or parameter sets, description of how it is used, and examples of how to use the
it. Try this:
Get-Help Get-Log
You should notice that it returns a brief synopsis of what Get-Log will do, the syntax for
usage, a more detailed description, and links associated with the cmdlet. If you're specii cally
looking for examples of how to use the cmdlet, simply use the -examples parameter:
Get-Help Get-Log -examples
There are several other parameters to choose from under the Remarks section, but the most
common to use are -full and -examples.
Connecting to vCenter Server and ESXi Hosts
The i rst cmdlet that any PowerCLI user has to know is Connect-VIServer. This cmdlet has
many features that make connecting to your vCenter Server or ESXi hosts easy. We'll go over
a few of those features in this section. If you'd like to see the full capabilities of Connect-
VIServer, you can check the PowerCLI help by entering the following:
get-help Connect-VIServer -full
Connecting to vCenter Server is the most common use of Connect-VIServer. To connect,
you'll need to provide at least the vCenter Server name, a username, and a password:
Connect-VIServer -server <vCenter Server Name> `
-user <username> -password <password>
This works well but is certainly not something you'd want to do with someone looking over
your shoulder or as part of a script that you may want to share. Including a password in plain-
text is simply asking for trouble. PowerCLI will natively use the user's credentials for the system
Search WWH ::




Custom Search