From dc523953cacedeeb0d00e22e6ea38b8ea9682111 Mon Sep 17 00:00:00 2001 From: Alan Comstock <31929022+Mr-Uptime@users.noreply.github.com> Date: Fri, 27 Oct 2017 09:25:47 -0500 Subject: [PATCH] Adds VLANs to an existing standard switch This script will add VLANs to an existing standard switch on a host. Information needed: $esxhost - Name of host $vswitch - Name of existing standard switch $vlanlist - List of all the VLANs you want to add to the switch --- Scripts/CreateVLANonStandardSwitch | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Scripts/CreateVLANonStandardSwitch diff --git a/Scripts/CreateVLANonStandardSwitch b/Scripts/CreateVLANonStandardSwitch new file mode 100644 index 0000000..d64b221 --- /dev/null +++ b/Scripts/CreateVLANonStandardSwitch @@ -0,0 +1,19 @@ +<# + Script name: CreateVLANonStandardSwitch.ps1 + Created on: 10/26/2017 + Author: Alan Comstock, @Mr_Uptime + Description: Adds VLANs to an existing standard switch + Dependencies: None known + PowerCLI Version: VMware PowerCLI 6.5 Release 1 build 4624819 + PowerShell Version: 5.1.14393.1532 + OS Version: Windows 10 +#> + +$esxhost="HOSTNAME" +$vswitch="vSwitch0" +$vlanlist=10,20,30,40,50 +Foreach ($vlan in $vlanlist) { + $portgroupname="VLAN " + $vlan + Get-VMHost $esxhost | Get-VirtualSwitch -name $vswitch | New-VirtualPortGroup -Name $portgroupname -VLanId $vlan +} +#The End