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 .