VCAP-DCA

Installing and configuring PowerCLI

In this article i am going to go over the steps to install and configure PowerCLI to run on my virtual center server. This will enable me to interrogate all the virtual machines and VMware environment by using Powershell.

1) The first step is to download Powershell v2.0 from Microsoft. Note this is only applicable if you are using Server 2003 or earlier. Powershell comes built into Server 2008 and Server 2008 R2. If you are running 2003 you can download it from here

2) Once you had downloaded and installed Powershell 2.0 you are then ready to download PowerCLI. If you go VMware.com and search for PowerCLI it should bring you to the download page. The version i have downloaded is PowerCLI v4.1.1. 

3) Once you have run the installation you will get a pop up box saying “This installation of VMware vSphere PowerCLI requires an additional component, “VMware VIX”, which will be installed automatically” You can just press OK to continue

4) Next you will see a screen pop up which mentions the Powershell execution policy. By default the Powershell installation is really locked down so you have to enable it to run your own scripts. To do this all you have to do is open up a powershell console and execute “Set-ExecutionPolicy RemoteSigned”

image

5) Now you have a few things to go through, just select next and accept the defaults (unless you want to change them of course!!) When the installation completes you should have 2 icons on your desktop for PowerCLI.  If you select one of them the PowerCLI menu will load up but there will be an error

image

This is because of what i mentioned in Step 4 so if you perform that command and reload you should be good to go

imageimage

6) OK so now you have your PowerCLI installed, what now? Next we have to connect to the vcenter web services. This step will enable us to start interrogating the environment. To do this we issue the following command:

connect-viserver -server virtualcenter -protocol http -user testlab\administrator  (obviously replacing virtualcenter with your vcenter server name)

imageimage

Once that connects successfully you should then be able to start issuing commands. As a test you can see i issued get-vm which recalls all the virtual machines in my environment.

Till next time!

Leave a Reply

Your email address will not be published. Required fields are marked *