Created
October 3, 2016 16:07
-
-
Save vmwarecode/de8822d4e59845187903f55c4d18d2e1 to your computer and use it in GitHub Desktop.
PowerCLI Script to create a VM in VCD using a Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################################################################## | |
#Script to create a Cloud VM from a template | |
######################################################################################################################## | |
#Setting up the powercli environment | |
C:\"Program Files (x86)"\VMware\Infrastructure\"vSphere PowerCLI"\Scripts\Initialize-PowerCLIEnvironment.ps1 | |
#Connecting to the CI Server | |
Connect-CIServer -server $hostname -User $username -Password $password | |
#Reading the required values from a .csv file stored in a specific location.Change the location accordingly | |
#OrgName : It is the VDC name where we want the VM to be powered on | |
#TemplateName : Name of the Template which is used for the VM deployment | |
#VMName : The Name to be used for the new VM creation | |
#ComputerName : The computer name that has to be assigned to the newly created VM | |
$vcloud_info = Import-Csv c:\scripts\info.csv | |
$orgvdcsName = $vcloud_info.OrgName | |
$TemplateName = $vcloud_info.TemplateName | |
$VMName = $vcloud_info.VMName | |
$CompName = $vcloud.ComputerName | |
$vapp = Get-CIVApp -OrgVdc $orgvdcsName | |
$vmtemplate = Get-CIVMTemplate -Name $TemplateName | |
New-CIVM -VApp $vapp.name -VMTemplate $vmtemplate.Name -Name $VMName -ComputerName $CompName | |
$vappnetwork = Get-CIVApp -Name $vapp.Name | Get-CIVAppNetwork | |
Get-CIVM -Name $VMName | Get-CINetworkAdapter | Set-CINetworkAdapter -VAppNetwork $vappnetwork -IPAddressAllocationMode Pool -Connected $true | |
Get-CIVM -Name $VMName | Start-CIVM | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment