I'm seeing a bunch of scripts to create new vlans, and add them to a distributed switch.
We currently have a bunch of existing vlans needing to be added to the same distributed switch, in a ESX 7.0 environment.
Ideally, I'd like to be able to import a list of vlans and add them to the distributed switch.
All help is greatly appreciated
For example, if you have the data in a CSV like this
Name,VLANId
Test1,100
Test2,101
you could do something like this
$dvSwName = 'vdSw1'
$dvs = Get-VDSwitch -Name $dvSwName
Import-Csv -Path .\portgroup.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
New-VDPortgroup -VDSwitch $dvs -Name $row.Name -VlanId $row.VLANId -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could take one of the scripts you found and run it in a foreach loop.
The loop can circle through all the input data (for example rows in a CSV).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
For example, if you have the data in a CSV like this
Name,VLANId
Test1,100
Test2,101
you could do something like this
$dvSwName = 'vdSw1'
$dvs = Get-VDSwitch -Name $dvSwName
Import-Csv -Path .\portgroup.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
New-VDPortgroup -VDSwitch $dvs -Name $row.Name -VlanId $row.VLANId -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you