This PowerCLI script will help you to deploy VMs in VMware Private vCloud and connect to network.
############################# # Deploy VMs in vCloud # ############################# # Change Log # 1.0 This script will Create vApp and deploy VMs from the selected TemplateVM. ################ # INITIALIZING # ################ ### DECLARING VARIABLES ### $vCloud_Server = "vCloud Server" # vCloud Server FQDN $vCloud_Org = "Org Name" # Org Name $orgNetwork = "orgNwName" # Target OrgNetworkName for the VM. $templateVM = "TemplateVMName # Template VM Name. $vmCount = 2 # No of VMs required. $vmIndex = 4 # VM starting index. $vAppNamePrefix = "RHEL-vApp" # Prefix string in the vApp Name. $VMNamePrefix = "RHEL-VM" # Prefix string in the VM Name. ### Connect to the vCloud Server ### Connect-CIServer $vCloud_Server ### Deploying VMs ### $vmCount = $vmIndex + $vmCount for($i=$vmIndex; $i -le $vmCount; $i++) { $vAppName = $vAppNamePrefix+"$i" $VMName = $VMNamePrefix+"$i" ### Creating new vApp ### New-CIVApp -Name $vAppName -OrgVdc $vCloud_Org ### Deploy the VM from template inside the newly created vApp### New-CIVM -Name "$VMName" -VMTemplate $templateVM -VApp $vAppName -ComputerName "$VMName" ### Creating new vApp Network ### New-CIVAppNetwork -VApp $vAppName -Direct -ParentOrgNetwork $orgNetwork $vAppNetwork = get-civapp $vAppName | Get-CIVAppNetwork $orgNetwork $cldVMs = get-civapp $vAppName | get-civm ### Connecting the vNIC to the network ### ### Please change the allocation model if required### foreach ($cldvm in $cldVMs) { $cldvm | Get-CINetworkAdapter | Set-CINetworkAdapter -vappnetwork $vAppNetwork -IPaddressAllocationMode Pool -Connected $True } ### Powering on the vApp ### get-CIVApp -Name $vAppName | Start-CIVApp } Disconnect-CIServer $vCloud_Server -Force -Confirm:$false