Hi all.
I have an esxi host 6.0.0 that I need to add a bunch of port/Vlan to it but they are a bunch , has any gone through the steps of adding this using PSCLI
Instead of adding one by one import a text file
Netowrk label VLAN ID
xxx.xxx.xxx.xxx 01
xxx.xxx.xxx.xxx 02
Thanks
Ok, you want to add a number of Portgroups?
That is quite straightforward.
Does the switch already exist?
From your screenshot it looks as if this is a VSS.
Correct?
In that case you could do something like this
$vssName = 'vSwitch1'
$esx = Get-VMHost -Name $esxName
$vss = Get-VirtualSwitch -Name $vssName -VMHost $esx
Import-Csv -Path .\pg.csv |
ForEach-Object -Process {
New-VirtualPortGroup -VirtualSwitch $vss -Name $_.'Network Label' -VLanId $_.'VLAN ID'
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can use my blog for this.PowerCLi Script to Automate to configure vSwitch, add Uplink and bulk virtual port groups
Ok, you want to add a number of Portgroups?
That is quite straightforward.
Does the switch already exist?
From your screenshot it looks as if this is a VSS.
Correct?
In that case you could do something like this
$vssName = 'vSwitch1'
$esx = Get-VMHost -Name $esxName
$vss = Get-VirtualSwitch -Name $vssName -VMHost $esx
Import-Csv -Path .\pg.csv |
ForEach-Object -Process {
New-VirtualPortGroup -VirtualSwitch $vss -Name $_.'Network Label' -VLanId $_.'VLAN ID'
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
L.
When running your script I get
"an empty pipe element is not allow"
Thanks
On which line?
Can you show the complete error message?
There is only 1 pipeline in that code, it's on the Import-Csv.
Did you copy the pipeline symbol (|) at the end of that line?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
L.
Right after the import-CSV
L.
PG.CSV file = xxx.xxx.xxx.xxx,xx
I had it working with no error by doing the following
Import-Csv -path .\pg.csv | Foreach-object {
But after it run NO portgroup is added to switch0 or host
L.
as always thank for your help, I was missing my header on my CSV therefore the loop was failing.
Thanks a bunch