diff --git a/common/Create-PortGroups.ps1 b/common/Create-PortGroups.ps1 new file mode 100644 index 0000000..c5708f4 --- /dev/null +++ b/common/Create-PortGroups.ps1 @@ -0,0 +1,45 @@ +<# +Creates PG-VLAN port groups on a vSwitch. + +Required parameter: + -SwitchName Name of the existing standard vSwitch. + +Example: + .\Create-PortGroups.ps1 -SwitchName vSwitch0 +#> +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)] + [string]$SwitchName +) + +$ErrorActionPreference = 'Stop' + +$portGroups = @( + @{ Name = 'PG-VLAN10'; VlanId = 10 }, + @{ Name = 'PG-VLAN11'; VlanId = 11 }, + @{ Name = 'PG-VLAN12'; VlanId = 12 }, + @{ Name = 'PG-VLAN20'; VlanId = 20 }, + @{ Name = 'PG-VLAN21'; VlanId = 21 }, + @{ Name = 'PG-VLAN23'; VlanId = 23 }, + @{ Name = 'PG-VLAN30'; VlanId = 30 }, + @{ Name = 'PG-VLAN51'; VlanId = 51 }, + @{ Name = 'PG-VLAN114'; VlanId = 114 }, + @{ Name = 'PG-VLAN211'; VlanId = 211 }, + @{ Name = 'PG-VLAN1130'; VlanId = 1130 }, + @{ Name = 'PG-VLAN1138'; VlanId = 1138 } +) + +$switch = Get-VirtualSwitch -Name $SwitchName -ErrorAction Stop + +foreach ($pg in $portGroups) { + $existing = Get-VirtualPortGroup -VirtualSwitch $switch -Name $pg.Name -ErrorAction SilentlyContinue + + if ($existing) { + Write-Host "$($pg.Name) already exists" + continue + } + + New-VirtualPortGroup -VirtualSwitch $switch -Name $pg.Name -VLanId $pg.VlanId | Out-Null + Write-Host "Created $($pg.Name) with VLAN $($pg.VlanId)" +} diff --git a/es2025/linux/Create-PortGroups.ps1 b/es2025/linux/Create-PortGroups.ps1 deleted file mode 100644 index 953da04..0000000 --- a/es2025/linux/Create-PortGroups.ps1 +++ /dev/null @@ -1,61 +0,0 @@ -<# -Required parameter: --SwitchName Name of the existing standard vSwitch where the port groups will be created. - -Optional parameter: --BaseVlanId Starting VLAN ID. Default is 100. - The script creates: - ES2025-LX-HQ-SERVER-Linux = BaseVlanId - ES2025-LX-HQ-DMZ-Linux = BaseVlanId + 1 - ES2025-LX-HQ-CLIENT-Linux = BaseVlanId + 2 - ES2025-LX-INET-HQ-Linux = BaseVlanId + 3 - ES2025-LX-INET-BRANCH-Linux = BaseVlanId + 4 - ES2025-LX-HOME-Linux = BaseVlanId + 5 - ES2025-LX-BR-SERVER-Linux = BaseVlanId + 6 - ES2025-LX-BR-CLIENT-Linux = BaseVlanId + 7 - -Example: -.\Create-PortGroups.ps1 -SwitchName vSwitch0 -#> -[CmdletBinding()] -param( - [Parameter(Mandatory = $true)] - [string]$SwitchName, - - [ValidateRange(1, 4087)] - [int]$BaseVlanId = 120 -) - -$ErrorActionPreference = 'Stop' - -$switch = Get-VirtualSwitch -Name $SwitchName -ErrorAction Stop - -$portGroups = @( - @{ Name = 'ES2025-LX-HQ-SERVER-Linux'; VlanId = $BaseVlanId }, - @{ Name = 'ES2025-LX-HQ-DMZ-Linux'; VlanId = $BaseVlanId + 1 }, - @{ Name = 'ES2025-LX-HQ-CLIENT-Linux'; VlanId = $BaseVlanId + 2 }, - @{ Name = 'ES2025-LX-INET-HQ-Linux'; VlanId = $BaseVlanId + 3 }, - @{ Name = 'ES2025-LX-INET-BRANCH-Linux'; VlanId = $BaseVlanId + 4 }, - @{ Name = 'ES2025-LX-HOME-Linux'; VlanId = $BaseVlanId + 5 }, - @{ Name = 'ES2025-LX-BR-SERVER-Linux'; VlanId = $BaseVlanId + 6 }, - @{ Name = 'ES2025-LX-BR-CLIENT-Linux'; VlanId = $BaseVlanId + 7 } -) - -foreach ($portGroup in $portGroups) { - $existing = Get-VirtualPortGroup -VirtualSwitch $switch -Name $portGroup.Name -ErrorAction SilentlyContinue - - if ($existing) { - if ($existing.VLanId -ne $portGroup.VlanId) { - Set-VirtualPortGroup -VirtualPortGroup $existing -VLanId $portGroup.VlanId | Out-Null - Write-Host "Updated $($portGroup.Name) VLAN to $($portGroup.VlanId)" - } - else { - Write-Host "$($portGroup.Name) already exists" - } - - continue - } - - New-VirtualPortGroup -VirtualSwitch $switch -Name $portGroup.Name -VLanId $portGroup.VlanId | Out-Null - Write-Host "Created $($portGroup.Name) with VLAN $($portGroup.VlanId)" -} diff --git a/es2025/windows/Create-PortGroups.ps1 b/es2025/windows/Create-PortGroups.ps1 deleted file mode 100644 index 9f7ae8f..0000000 --- a/es2025/windows/Create-PortGroups.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -<# -Required parameter: --SwitchName Name of the existing standard vSwitch where the port groups will be created. - -Optional parameter: --BaseVlanId Starting VLAN ID. Default is 120. - The script creates: - ES2025-WIN-INET = BaseVlanId - ES2025-WIN-CPH-INT = BaseVlanId + 1 - ES2025-WIN-CPH-DEV = BaseVlanId + 2 - ES2025-WIN-AAL-INT = BaseVlanId + 3 - -Example: -.\Create-PortGroups.ps1 -SwitchName vSwitch0 -#> -[CmdletBinding()] -param( - [Parameter(Mandatory = $true)] - [string]$SwitchName, - - [ValidateRange(1, 4091)] - [int]$BaseVlanId = 130 -) - -$ErrorActionPreference = 'Stop' - -$switch = Get-VirtualSwitch -Name $SwitchName -ErrorAction Stop - -$portGroups = @( - @{ Name = 'ES2025-WIN-INET'; VlanId = $BaseVlanId }, - @{ Name = 'ES2025-WIN-CPH-INT'; VlanId = $BaseVlanId + 1 }, - @{ Name = 'ES2025-WIN-CPH-DEV'; VlanId = $BaseVlanId + 2 }, - @{ Name = 'ES2025-WIN-AAL-INT'; VlanId = $BaseVlanId + 3 } -) - -foreach ($portGroup in $portGroups) { - $existing = Get-VirtualPortGroup -VirtualSwitch $switch -Name $portGroup.Name -ErrorAction SilentlyContinue - - if ($existing) { - if ($existing.VLanId -ne $portGroup.VlanId) { - Set-VirtualPortGroup -VirtualPortGroup $existing -VLanId $portGroup.VlanId | Out-Null - Write-Host "Updated $($portGroup.Name) VLAN to $($portGroup.VlanId)" - } - else { - Write-Host "$($portGroup.Name) already exists" - } - - continue - } - - New-VirtualPortGroup -VirtualSwitch $switch -Name $portGroup.Name -VLanId $portGroup.VlanId | Out-Null - Write-Host "Created $($portGroup.Name) with VLAN $($portGroup.VlanId)" -} diff --git a/ws2024/linux/Create-PortGroups.ps1 b/ws2024/linux/Create-PortGroups.ps1 deleted file mode 100644 index 317d25f..0000000 --- a/ws2024/linux/Create-PortGroups.ps1 +++ /dev/null @@ -1,51 +0,0 @@ -<# -Required parameter: --SwitchName Name of the existing standard vSwitch where the port groups will be created. - -Optional parameter: --BaseVlanId Starting VLAN ID. Default is 100. - The script creates: - WS2024-LX-WAN-Linux = BaseVlanId - WS2024-LX-INT-Linux = BaseVlanId + 1 - WS2024-LX-DMZ-Linux = BaseVlanId + 2 - -Example: -.\Create-PortGroups.ps1 -SwitchName vSwitch0 -#> -[CmdletBinding()] -param( - [Parameter(Mandatory = $true)] - [string]$SwitchName, - - [ValidateRange(1, 4092)] - [int]$BaseVlanId = 100 -) - -$ErrorActionPreference = 'Stop' - -$switch = Get-VirtualSwitch -Name $SwitchName -ErrorAction Stop - -$portGroups = @( - @{ Name = 'WS2024-LX-WAN-Linux'; VlanId = $BaseVlanId }, - @{ Name = 'WS2024-LX-INT-Linux'; VlanId = $BaseVlanId + 1 }, - @{ Name = 'WS2024-LX-DMZ-Linux'; VlanId = $BaseVlanId + 2 } -) - -foreach ($portGroup in $portGroups) { - $existing = Get-VirtualPortGroup -VirtualSwitch $switch -Name $portGroup.Name -ErrorAction SilentlyContinue - - if ($existing) { - if ($existing.VLanId -ne $portGroup.VlanId) { - Set-VirtualPortGroup -VirtualPortGroup $existing -VLanId $portGroup.VlanId | Out-Null - Write-Host "Updated $($portGroup.Name) VLAN to $($portGroup.VlanId)" - } - else { - Write-Host "$($portGroup.Name) already exists" - } - - continue - } - - New-VirtualPortGroup -VirtualSwitch $switch -Name $portGroup.Name -VLanId $portGroup.VlanId | Out-Null - Write-Host "Created $($portGroup.Name) with VLAN $($portGroup.VlanId)" -} diff --git a/ws2024/windows/Create-PortGroups.ps1 b/ws2024/windows/Create-PortGroups.ps1 deleted file mode 100644 index 63db69c..0000000 --- a/ws2024/windows/Create-PortGroups.ps1 +++ /dev/null @@ -1,57 +0,0 @@ -<# -Required parameter: --SwitchName Name of the existing standard vSwitch where the port groups will be created. - -Optional parameter: --BaseVlanId Starting VLAN ID. Default is 200. - The script creates: - WS2024-WIN-Paris-Core = BaseVlanId - WS2024-WIN-Paris-Dist = BaseVlanId + 1 - WS2024-WIN-Paris-Client = BaseVlanId + 2 - WS2024-WIN-LA-Paris = BaseVlanId + 3 - WS2024-WIN-LA-Lyon = BaseVlanId + 4 - WS2024-WIN-Lyon-Remote = BaseVlanId + 5 - -Example: -.\Create-PortGroups.ps1 -SwitchName vSwitch0 -#> -[CmdletBinding()] -param( - [Parameter(Mandatory = $true)] - [string]$SwitchName, - - [ValidateRange(1, 4089)] - [int]$BaseVlanId = 110 -) - -$ErrorActionPreference = 'Stop' - -$switch = Get-VirtualSwitch -Name $SwitchName -ErrorAction Stop - -$portGroups = @( - @{ Name = 'WS2024-WIN-Paris-Core'; VlanId = $BaseVlanId }, - @{ Name = 'WS2024-WIN-Paris-Dist'; VlanId = $BaseVlanId + 1 }, - @{ Name = 'WS2024-WIN-Paris-Client'; VlanId = $BaseVlanId + 2 }, - @{ Name = 'WS2024-WIN-LA-Paris'; VlanId = $BaseVlanId + 3 }, - @{ Name = 'WS2024-WIN-LA-Lyon'; VlanId = $BaseVlanId + 4 }, - @{ Name = 'WS2024-WIN-Lyon-Remote'; VlanId = $BaseVlanId + 5 } -) - -foreach ($portGroup in $portGroups) { - $existing = Get-VirtualPortGroup -VirtualSwitch $switch -Name $portGroup.Name -ErrorAction SilentlyContinue - - if ($existing) { - if ($existing.VLanId -ne $portGroup.VlanId) { - Set-VirtualPortGroup -VirtualPortGroup $existing -VLanId $portGroup.VlanId | Out-Null - Write-Host "Updated $($portGroup.Name) VLAN to $($portGroup.VlanId)" - } - else { - Write-Host "$($portGroup.Name) already exists" - } - - continue - } - - New-VirtualPortGroup -VirtualSwitch $switch -Name $portGroup.Name -VLanId $portGroup.VlanId | Out-Null - Write-Host "Created $($portGroup.Name) with VLAN $($portGroup.VlanId)" -}