Wednesday, June 15, 2011

Add vLAN to ESX host

#clear screen
cls
#remove any lingering variables
Remove-Variable -Name * -Force -ErrorAction SilentlyContinue
#add VMware snapin
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
#vCenter is the fqdn of your vCenter
Connect-VIServer -Server vCenter 
#Cluster1 is the name of your cluster
foreach ($ESXhost in get-cluster Cluster1 | get-vmhost)
{
  #VSWITCH1 is the name of your virtual swtich
  get-virtualswitch -vmhost $ESXhost -name VSWITCH1 | new-virtualportgroup -name vLAN_201 -vlanid 201
}

No comments:

Post a Comment