Essentially, the script should:
Configure DNS for esxi host
Configure NTP for esxi host
create port groups
add applicable vmnics and add to applicable port groups
set vlans for port groups
I've hacked an existing script I found on the internet, but having trouble with the following (and put a comment for the section I'm unsure of):
write-host "Configuring vSwitch0"
$vs0 = Get-VirtualSwitch -Name vSwitch0
Set-VirtualSwitch -VirtualSwitch $vs0 -Nic $esxnics
New-VMHostNetworkAdapter -PortGroup VMkernel -VirtualSwitch $vs0 -IP $VMotionIP -SubnetMask $VMotionSubnet -VMotionEnabled: $true
New-VMHostNetworkAdapter -PortGroup ProdLAN1 -VirtualSwitch $vs0
Set-VirtualPortGroup -VirtualPortGroup "ProdLAN1" -VLanId "10"
New-VMHostNetworkAdapter -PortGroup SvrMgmtLAN1 -VirtualSwitch $vs0
Set-VirtualPortGroup -VirtualPortGroup "SvrMgmtLAN1" -VLanId "101"
New-VMHostNetworkAdapter -PortGroup NetMgmtLAN1 -VirtualSwitch $vs0
Set-VirtualPortGroup -VirtualPortGroup "NetMgmtLAN1" -VLanId "103"
New-VMHostNetworkAdapter -PortGroup CritLAN40 -VirtualSwitch $vs0
Set-VirtualPortGroup -VirtualPortGroup "CritLAN40" -VLanId "40"
New-VMHostNetworkAdapter -PortGroup CritLAN42 -VirtualSwitch $vs0
Set-VirtualPortGroup -VirtualPortGroup "CritLAN42" -VLanId "42"
New-VMHostNetworkAdapter -PortGroup CritLAN50 -VirtualSwitch $vs0
Set-VirtualPortGroup -VirtualPortGroup "CritLAN50" -VLanId "50"
New-VMHostNetworkAdapter -PortGroup VDIClientLAN3030 -VirtualSwitch $vs0
Set-VirtualPortGroup -VirtualPortGroup "VDIClientLAN3030" -VLanId "3030"
I've attached a text file (from esxi v4) of what I want to acheive (in terms of the vswitch config):
--add vSwitch0
--del-pg "VM Network" vSwitch0
--link vmnic1 vSwitch0
--add-pg vMotion vSwitch0
--add-pg ProdLAN1 vSwitch0
--add-pg SvrMgmtLAN1 vSwitch0
--add-pg NetMgmtLAN1 vSwitch0
--add-pg CritLAN40 vSwitch0
--add-pg CritLAN42 vSwitch0
--add-pg CritLAN50 vSwitch0
--add-pg VDIClientLAN3030 vSwitch0
-p vMotion --vlan 101 vSwitch0
-p ProdLAN1 --vlan 10 vSwitch0
-p SvrMgmtLAN1 --vlan 101 vSwitch0
-p NetMgmtLAN1 --vlan 103 vSwitch0
-p CritLAN40 --vlan 40 vSwitch0
-p CritLAN42 --vlan 42 vSwitch0
-p CritLAN50 --vlan 50 vSwitch0
-p VDIClientLAN3030 --vlan 3030 vSwitch0
Any assistance would be GREATLY appreciated.
The script you got from the Internet starts from an existing vSwitch (called vSwitch0).
It then adds vmnic0 and vmnic8 to this vSwitch.
Followed by adding a number of portgroups to the vSwitch.
So first, do you have that vSwitch0 and vmnic0/vmnic8 on your ESXi servers ?
If yes, are you getting any error messages ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference