What is vSphere PowerCLI?
vSphere PowerCLI provides easy-to-use C# and PowerShell interface to VMware vSphere APIs. It ships with a number of cmdlets that you can use to perform various administration tasks on VMware vSphere components
Installation Pre-Requisites
- .NET 2.0 SP1
- Windows PowerShell 1.0/2.0/3.0
Supported Operating Systems
VMware vSphere PowerCLI 5.0 is supported on the 32-bit and 64-bit versions of the following Windows operating systems:
- Windows 7
- Windows Server 2008
- Windows Vista
- Windows XP Service Pack 2
- Windows 2003 Server Service Pack 2
Supported VMware Environments
vSphere PowerCLI 5.0 is compatible with the following VMware environments:
- VMware ESXi 5.0
- vCenter Server 5.0
- VMware ESX 4.1/vCenter Server 4.1
- VMware ESXi 4.1
- VMware ESX 4.0 Update 2/vCenter Server 4.0 Update 2
- VMware ESX 4.0 Update 1/vCenter Server 4.0 Update 1
- VMware ESX 4.0i Update 1
- VMware ESX 3.5 Update 5
- VMware ESXi 3.5 Update 5
- VMware VirtualCenter 2.5 Update 6
- VMware ESX 3.0.3 Update 1
Identify Cmdlet Concepts
PowerShell cmdlets use a consistent verb-noun structure, where the verb specifies the action and the noun specifies the object to operate on. PowerShell cmdlets follow consistent naming patterns, which makes it easy to figure out how to construct a command if you know the object you want to work with.
All command categories take parameters and arguments. A parameter starts with a hyphen and is used to control the behavior of the command. An argument is a data value consumed by the command.
PowerCLI Components
To use these snap-ins, you must add them using the add-pssnapin cmdlet.
Example
- add-pssnapin vmware.vimautomation.core
Installing
- Download PowerCLI from the VMware website
- Click the exe and install
- You may get a message such as below
- And this message – Click Continue
- Click Next
- Click Next
- Click Next
- Keep the default selection
- Click Install
Configuring PowerCLI
Set the properties for Remote Signing
For security reasons, Windows PowerShell supports an execution policy feature. It determines whether scripts are allowed to run and whether they must be digitally signed. By default, the execution policy is set to Restricted, which is the most secure policy. If you want to run scripts or load configuration files, you can change the execution policy by using the Set-ExecutionPolicy cmdlet. For more information about the execution policy and script digital signing in Windows PowerShell, run Get-Help About_Signing.
- Right click on the PowerCLI icon and selecy Run as Administrator
- Type Set-ExecutionPolicy RemoteSigned
Slow Startup
I experienced a really slow start-up from PowerCLI. It had something to do with internet access and checking the certificates. I disabled this by doing the below
- Open the Control Panel → Go To Internet Options → Go to the Advanced tab → Go to the Security Section
- Un-check the “Check for publisher’s certificate revocation” check-box
Certificate Errors
Certificate error can generally be ignored but if you want to make sure they don’t come up try typing the following
- Set-PowerCLIConfiguration -invalidCertificateAction ignore -confirm:$false
Guides
PowerShell Community
http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli
Leave a Reply