Jesse Mayfield
asked on
Creating 2 network Adapters via PowerCli
I'm having an issue creating 2 network adapters for my SQL VM. Here is what I've tried and I keep getting errors. I believe the issue may be I'm not calling the second nic correctly. The script works but adding the second nic fails.
Connect-VIServer -Server -User njes\ -Password
# Create all the VMs specified in $newVmList
$newVmList = "MV-DATACOM-M3-X"
# Specify the VM you want to clone
$mySourceTemplate = Get-Template -Name "win2k12R2stdScanned_enhanced_template"
#
# Specify the Customization Specification to use
$customspecification= "Windows_2012_std_R2_template"
# Specify the datastore or datastore cluster placement
$ds = "ham_dev1"
#
$vmhost = Get-VMHost -Name cdlisdev
#
# Specify vCenter Server Virtual Machine & Templates folder
$Folder = "Templates"
#
# Specify the vSphere Cluster
$Cluster = "CDLIS"
#
# End of user input parameters
#_______________________________________________________
#
$newVmList | ForEach-Object {
$VM_name= $_
$ESXi=Get-Cluster $Cluster | Get-VMHost -state connected | Get-Random
write-host "Creation of VM $VM_name initiated” -foreground green
New-VM -Name $VM_Name -Template $mySourceTemplate -VMHost $ESXi -Datastore $ds -Location $Folder -OSCustomizationSpec $customspecification
Start-VM $VM_Name
Start-Sleep 600 # seconds
Get-VM $VM_Name | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName HOSTING_3918 -Confirm:$false
Get-VM $VM_Name | Get-NetworkAdapter | Set-NetworkAdapter 2 -NetworkName HOSTING_3918 -Confirm:$false
}
ASKER
The template has 1 adapter. I would like to add additional adapter after the template has completed customization.
in powercli type
new-net , then desperately tap on tab until you get all options right
new-net , then desperately tap on tab until you get all options right
ASKER
I have tried the get new-network adapter but it only works for 1 nic. I need to add a second nic and It doesn't take when I use new-network adapter 2.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
In your shole script you do not add any network adapter, just map one found to some network.