Installing powercli.


I spoke with some people and noticed that not everyone is familiar with scripting vmware VI using powershell. I thought i would made a post with how to obtain/install what is needed to get it done.

1) Go to http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli

2) download VMware-PowerCLI-4.1.1-332441.exe

3) Start installing powercli, you might encounter an error sayin that powershell 1.0 is not installed. In this case you will have to also download windows powershell. For XP O/S you can download using this url:

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=60cb5b6c-6532-45e0-ab0f-a94ae9ababf5&displaylang=en

If you have other O/S please download the right version for you:

http://support.microsoft.com/kb/968930

3)while installing powercli, you will be asked if installer can change for you the execution policy to “Remote Signed”. You should choose “Do this For Me”. If you click Continue, you will have to do this manually after installation. Execution policy is well described here:
http://technet.microsoft.com/en-us/library/ee176949.aspx
You can always verify it by invoking cmd-let:
Get-ExecutionPolicy
and set it by invoking
Set-ExecutionPolicy
You can also read manual within powershell about ExecutionPolicy typing:
Get-Help About_Signing

4)We will need some editor for our scripts(although you can write directly under powershell.exe).

You can use editor that comes with powershell – Powershell ISE, or you can try PowerGUI from http://www.powergui.org

5) I assume, that all went right, and you can start powercli console : start->programs->vmware->powercli

After powercli initializes its environment, you can test you connection to ESX/VC.

Simply type:

connect-viserver IP_ESX//IP_VC

Connect-viserver without any switches will ask you after few seconfs for credentials.

If you typed user/password without issues you will see something like this:

Name                           Port  User
—-                           —-  —-
Esx/Vc IP                 443   Logged_User

It means that you can start scripting 😉 Try some basic cmd-lets like:

get-vm / get-vmhost , try what stands behind get-cmd

That’s it for now, in next few days i will write more about powercli basics.  If you have encountered any problems, let me know.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s