Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 181080

PowerCli, vCloud Director Configure NIC, Import

$
0
0

Having problems getting my PowerCli script to fully import a VM as well as configuring the Organization VDC network within the VM guest.

 

Hoping someone could take a quick look at what I have below (Not working) and advise what code I'd need to add to fully configure the Network on this after a successful import into vDC

 

#Add correct Snapins for vCenter Server, and vCloud Director

Add-PSSnapin VMware.VimAutomation.Core

Add-PSSnapin vmware.vimautomation.cloud

clear

 

 

#Predefined Variables

$ciServerNED = 'ciserver1'

$ciServerMAR = 'ciserver2'

$viServerNED = 'viserver1'

$viServerMAR = 'viserver2'

$ciName = $viName

$vApp = $ciName

 

 

#Prompts

$viName = Read-Host "VM Guest?"

$org = Read-Host "VM Organization?"

$viServer = Read-Host "Virtual Center Name?"

$location = Read-Host "NED, or MAR?"

$ciNetwork = Read-Host "VDC_Network_Name?"

$ciNetwork2 = Read-Host "VDC_Network_Name2?"

$ciNetworkIP = Read-Host "Network 1 IP?"

$ciNetworkIP2 = Read-Host "Network 2 IP (Press Enter for NULL)?"

 

 

if ($location -eq 'NED')

{

$ciServer = $ciServerNED

$viServer = $viServerNED

}

else

{

$ciServer = $ciServerMAR

$viServer = $viServerMAR

}

#Connecting to Virtual Center, and vCloud Director

Connect-VIServer -Server $viServer

Connect-CIServer -Server $ciServer

 

 

#Import Process

Import-CIVApp -VM (Get-VM $viName) -OrgVdc $org -NoCopy:$True -RunAsync #-Confirm $false

Start-Sleep -s 30

$ciName | Get-CINetworkAdapter | Set-CINetworkAdapter -vappnetwork $ciNetwork -IPaddressAllocationMode:Pool -Connected:$True

Set-NetworkAdapter -NetworkAdapter $ciNetwork -WakeOnLan:$true -StartConnected:$true -Connected:$true

 

 

Start-Sleep -s 30

 

 

#Starting VM Guest through vCloud Director

Start-CIVM -VM $viName

 

 

#Disconnecting from vCenter, and vCloud Director

Disconnect-VIServer -Server $viServer -Confirm:$false

Disconnect-CIServer -Server $ciServer -Confirm:$false

 

 

#Pop-up indicating the script has finished

$a = new-object -comobject wscript.shell

$b = $a.popup("Script has completed",0,"Script has completed",1)


Viewing all articles
Browse latest Browse all 181080

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>