VCAP6-DCV Deploy Objective 5.1

Objective 5.1 of VCAP6-Deploy exam covers following topics:

  • Install and configure vSphere PowerCLI
  • Use basic and advanced PowerCLI Cmdlets to manage a vSphere deployment
  • Analyze a sample script, then modify the script to perform a given action
  • Use PowerCLI to configure and administer Auto Deploy (including Image Builder)
  • Create a report from a PowerCLI script

Lets walk through each topic one by one.

                                           Install and configure vSphere PowerCLI

Installation of PowerCLI is pretty straight forward. Just run the installer and hit Next..Next.

Once the installation is completed, we will need to set the Execution Policy prior to executing any command via PowerCLI. 

Set the Execution Policy by running comamnd: Set-ExecutionPolicy RemoteSigned

pcli-1.PNG

Current execution policy can be checked by running command: Get-ExecutionPolicy

             Use basic and advanced PowerCLI Cmdlets to manage a vSphere deployment

It is not possible to show all PowerCLI commands here as the list is very long. Pluralsight have an advanced management course on using PowerCLI. VMware official documentation on this topic can be found here.

It is unclear that what kind of questions can be asked in VCAP6-Deploy exam on this topic but if you can use PowerCLI you can save a lot of time in the exam instead of waiting for the Web Client to respond / refresh.

To see a full list of all VMware related Cmdlets run the following command : Get-Command -Module vmware* |more

pcli-3.PNG

Connect to a vCenter Server System

Basic commands to managed VM’s:

a: Get-VM: List all VM’s in the inventory

pcli-9.PNG

b: Get-VMGuest: Retrieve info about the OS

pcli-10.PNG

c: Start-VM – starting the VM

d: Stop-VM: Power off the VM

Get Datastore : list information on all Datastores

pcli-8.PNG

Get-VmHost – list all hosts

pcli-6.PNG

Put a host in a variable

Put host in maintenance mode

Remove host out of maintenance mode

Get-NetworkAdapter: List network adapters present in VM’s

pcli-11.PNG

                          Analyze a sample script, then modify the script to perform a given action

VMware’s documentation list some examples of PowerCLI scripts which can be found here

You can use a specification provided in an XML file to automate the creation of virtual machines on vCenter Server. Here is a sample xml file for creating a test vm with 40 GB disk space

Procedure

1: Read the content of the myVM.xml file.

2: Create the virtual machines.

Note that you should have defined variable $VMHost earlier for this command to work

                      Use PowerCLI to configure and administer Auto Deploy (including Image Builder)

Step 1: Connect to vCenter Server

# Connect-VIServer -Server vcentersrv01.alex.local -Username vcadmin@alex.local

Step 2: Add ESXi to the Software Depot

Go to www.vmware.com and click on the version of ESXi you wish to use. Download the “ESXi Offline Bundle” ZIP file”. I am using Esxi 6.0 U3 in my lab and it can be downloaded from here

Place the zip file anywhere in your system, but remember the path. Do not unzip this file as you will need the full ZIP file for Auto Deploy.

Step 3: View/Verify the Image Profiles

ad-10.png

Step 4: Clone the Image Profile

ad-11.png

Step 5: Verify the New Image Profile

ad-12

Step 6: Add the HA Agent Depot

ad-13.PNG

Step 7: Add the HA Agent Package to the Image Profile

ad-14.PNG

Step 8: Add a Deploy Rules

A Deploy rule is used to determine which hosts boot a specific version of ESXi. There are two important pieces of information needed to create the deploy rule; items and patterns. The items determine what object to associate to the ESXi host and the patterns determine which ESXi hosts are a part of the specific rule.

An example of deploy rule is shown below:

Step 10: Activate the Deploy Rule

Add-DeployRule Esxi6.0U3

                                                Create a report from a PowerCLI script

PowerCLI commands can be exported into different formats for creating reports, the following commands are the export options.

  • Export-Csv
  • Export-Clixml
  • ConvertTo-Csv
  • ConvertTo-Html
  • ConvertTo-Xml

Examples

1: Export all VM information to a CSV file

Opening the vmlist.csv file will give you details of all the VM that are in the vCenter inventory

vmlist.PNG

2: Export all host information within a cluster in HTML file

This is how output looks.

hosts.PNG

3: Get list of all running VM’s

running-vm.PNG

4: Retrieve status of Esxi host in a datacenter

pcli-7

I hope you find this post informational. Feel free to share this on social media if it is worth sharing. Be sociable 🙂

Leave a Reply