In this blog I will show you how to deploy a vApp using PowerCLI.
One of the cool things about vCloud is that you can create vApp templates.
An example of a template could be a set of servers that is always needed when deploying a new environment. For instance a file server, an application server and one or better yet two domain controllers.
To find out more about templates and how to use them please visit Working with vApp Templates on the VMware website.
In the example below I assume there is already a vApp template created named ‘Customer template’ and that some parameters have been setup before hand.
Now we can run the script to deploy a vApp using Powercli.
param(
[Parameter(Mandatory=$True)]
[System.Management.Automation.PSCredential]$Credential,
[Parameter(Mandatory=$True)]
[string]$Newcustomer
)
#Name of of your Virtual Datacenter
$orgvdcsName = 'example-OrgvDC'
#Name of the template in the catalog
$vappTemplateName = 'Customer template'
#Connect to the virtual datacenter.
Connect-CIServer -server xxx.yyy.zzzz -org "example" -Credential $Credential
#Create new vApp and deploy to the proper organization
New-CIVApp -VAppTemplate $vappTemplateName -Name $Newcustomer -OrgVdc $orgvdcsName
#Start the vApp
Get-CIVApp -Name $Newcustomer|Start-CIVApp
#Disconnect your session.
Disconnect-CIServer -Server * -Confirm:$false
To find out more info on how to add credential parameters to Powershell functions please visit: http://duffney.io/AddCredentialsToPowerShellFunctions
*The script is inspired upon a script of a colleague of mine.
Check our other vCloud Director related articles here