Preparing VMware PowerCLI for first use

All the tasks performed on the Auto Deploy server are done using VMware PowerCLI commands. Hence, it is a requirement to have VMware vSphere PowerCLI installed and configured for use.

At the time of writing this book, the latest available version was VMware-PowerCLI-5.0.1-581491. Download and install VMware PowerCLI from the following URL:

www.vmware.com/go/powercli

The installation of PowerCLI is pretty straight-forward. Just go through the wizard defaults and finish the installation. Once the installation is complete, it needs to be configured so that it can be used in your environment.

How to do it…

The following procedure will help you configure VMware PowerCLI for first use and also add the vCenter Server that will be used to manage the ESXi servers which you plan to deploy in your environment:

  1. If VMware PowerCLI is being installed for the first time, you need to make sure that you issue the command to set the execution policy to either RemoteSigned or Unrestricted, by issuing any of the following commands:
    Set-ExecutionPolicy Unrestricted
    

    Or

    Set-ExecutionPolicy RemoteSigned
    
  2. Close the PowerCLI window and re-open it. You should see vSphere PowerCLI welcome screen.
  3. Connect the vCenter Server to VMware PowerCLI, by issuing the following command:

    Syntax:

    Connect-VIServer FQDN or IP address of the vCenter
    

    Example:

    Connect-VIServer vcenter51.vdescribed.com
    

How it works…

VMware PowerCLI is a set of cmdlets based on Microsoft Power Shell.

The Set-Execution policy cmdlet will determine what type of PowerCLI commands/scripts are allowed to run from the computer where VMware PowerCLI is installed. There are four types of execution policy, such as Restricted, AllSigned, RemoteSigned, and Unrestricted.

The default execution policy is Restricted, which does not allow running any scripts.

  • Setting it to RemoteSigned will allow running scripts/cmdlets signed by a trusted publisher, in this case VMware Inc.
  • Setting it to Unrestricted will impose no restrictions.

The Connect-VIServer cmdlet can be used to connect either the vCenter Server or the ESXi host. But for you to be able to address Clusters, Folders, and Host Profiles when creating a deploy rule, you will need vCenter level access. Therefore, you will need to connect to the vCenter Server and not the ESXi server.