Well, I’m currently migrating between different cluster layouts, and I had to create the new PortGroups on the old hosts, in order for me to switch between old and new hosts.

1
2
3
4
5
6
7
$vmhosts = Get-Cluster "UCSCL01-02" | Get-VMHost
foreach ($vmhost in $vmhosts) {
  import-csv -Delimiter ";" .\pg.csv | foreach {
    $vmhost | Get-VirtualSwitch -Name "vSwitch3" | New-VirtualPortGroup `
                                -Name $_.portgroup -VLanId $_.vlanid
  }
}

And the corresponding CSV would look like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
portgroup;vlanid
1700_routers;1700
1701_routers;1701
1702_routers;1702
1703_routers;1703
1704_routers;1704
1705_routers;1705
1706_routers;1706
1707_routers;1707
1708_routers;1708
1709_routers;1709
1710_routers;1710
1711_routers;1711
1712_routers;1712
1713_routers;1713
1714_routers;1714
1715_routers;1715
1716_routers;1716
1717_routers;1717
1718_routers;1718
1719_routers;1719
2000_virtual-machines;2000
2001_virtual-machines;2001
2002_virtual-machines;2002
2003_virtual-machines;2003
2004_virtual-machines;2004
2005_virtual-machines;2005
2006_virtual-machines;2006
2007_virtual-machines;2007
2008_virtual-machines;2008
2009_virtual-machines;2009
2010_virtual-machines;2010
2011_virtual-machines;2011
2012_virtual-machines;2012
2013_virtual-machines;2013
2014_virtual-machines;2014
2015_virtual-machines;2015
2016_virtual-machines;2016
2017_virtual-machines;2017
2018_virtual-machines;2018
2019_virtual-machines;2019