Home > Blogs > VMware PowerCLI Blog

Preparing the hosts in Provider VDCs with PowerCLI

Posted by
Alan Renouf
Technical Marketing

Following my previous post where I showed how easy and quick it was to create a Provider VDC there was a step which we needed to complete before the Provider VDC would be available to use, if you took note of the last screenshot it looked the same as below:


The more attentive of you will have noticed the system alerts on the status, this is because we had not prepared the hosts within our cluster to be used with vCloud Director.  When first adding ESXi hosts to a VCD Provider VDC an agent is needed on the hosts, Chris Colotti explained recently what this agent was needed for here.

There are two ways to add this agent, the first is to include it in your ESXi Image, this is explained here and can also be used with Auto Deploy, if it is not pre-included in the ESXi build then it will need to be installed after the hosts have joined VCD.

To do this we can use the below script on each host in the Provider VDC:

Function Prepare-CIHost {
    Param (
    $Search = Search-cloud -QueryType Host -Name $CIHost
    $HostView = Get-CIView -SearchResult $Search
    $HostView.Prepare($password, $username)

Prepare-CIHost -CIHost "ESXiHost1" -Username "root" -Password "Pa$$w0rd"

There are a couple of interesting techniques in this simple script, use of the –SearchResult parameter in the Get-CIView cmdlet can be very handy, If you are looking into automating VCD with PowerCLI I suggest you look at this further.

Another cmdlet used in this script is the Search-Cloud, again a very useful cmdlet which allows you to find objects in the Cloud very fast.  More examples and details of the Search-Cloud cmdlet will be mentioned in a future post.

Get notification of new blog postings and more by following VMware PowerCLI on Twitter: @PowerCLI

This entry was posted in Advanced on by .
Alan Renouf

About Alan Renouf

Alan Renouf is a Product Line Manager at VMware focusing on API's, SDK's and CLI's, He is responsible for providing the architects and operators of private and public cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/PowerCLI a book author and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

Leave a Reply

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