Saturday, 2 August 2014

Power CLI primer

Just like many of the network professionals out here , I too believe that life is too short to learn all those command prompt tools and stick on to a graphical version of any tool if it is available . But some times the command prompt based tools can be indispensable if you have to do things repeatedly . For creating a single VM per day , I will surely use vsphere client , but for 50 VM per day , I prefer some method by which I can automate the process. That is the role the power CLI is playing in a vSphere environment .
This post is just a basic introduction in to the basic aspects of power CLI. Personally I am preparing this as a reference to me itself so that I will not miss any of the concepts of power CLI for my VCAP-DCA exam .
to begin your experiment with powerCLI , install it to any windows machine on your network . You can download it here 
installation is pretty straightforward . Finish it and open power CLI from all programs --vmware --vmware power CLI . but  wait , if you try to do it , you will be greeted with an error message like this .




Now try to open the same program with administrative privileges , ie right click and select run as administrator , you will find that the same error repeats this time also . But it is now time for us to set the execution policy of the PowerCLI to " remoteSigned " it will allow us to run scripts that have written on the local computer . That is exactly what we need to do . The default mode is restricted and that is why we are getting all those red colored scary messages . so go ahead and type this
set -executionPolicy Remotesigned
next time when you bring the powerCLI up , it will greet you in a much more pleasant manner . Remember that you don't have to run it in administrative mode anymore for normal operations .



Now let us start by connecting to an ESXi host  or a vCenter Server . use the command   connect-Viserver  < ipadress or FQDN >
it will pop up a message asking for the user name and password . There are two option to avoid  it and specify it along with the commands
connect-viserver < ipaddress>  -user root -password P@ssw0rd  or you can use the credential variable  $Credential=Get-Credential and using the value $credential along with the command like  connect-viserver< ipaddress>  -credential $credential 


connect-VIserver -Menu is a nice option to list all your previously connected servers and you can choose one to which you wish to connect .






2 comments:

  1. Thanks for providing this informative information…..
    You may also refer- http://www.s4techno.com/blog/category/vmware/

    ReplyDelete
  2. I have definitely picked up anything new from right here. I did however expertise a few technical points using this site, since I experienced to reload the web site a lot of times previous to I could get it to load correctly.

    VMware Training in Chennai

    ReplyDelete