Add unfinished scripts for building Linux topology

This commit is contained in:
2026-04-17 07:37:19 +02:00
parent 3b14aa7c2b
commit f28b403e4b
4 changed files with 806 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
<#
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:
HQ-SERVER-Linux = BaseVlanId
HQ-DMZ-Linux = BaseVlanId + 1
HQ-CLIENT-Linux = BaseVlanId + 2
INET-HQ-Linux = BaseVlanId + 3
INET-BRANCH-Linux = BaseVlanId + 4
HOME-Linux = BaseVlanId + 5
BR-SERVER-Linux = BaseVlanId + 6
BR-CLIENT-Linux = BaseVlanId + 7
Example:
.\Create-PortGroups.ps1 -SwitchName vSwitch0
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$SwitchName,
[ValidateRange(1, 4087)]
[int]$BaseVlanId = 100
)
$ErrorActionPreference = 'Stop'
$switch = Get-VirtualSwitch -Name $SwitchName -ErrorAction Stop
$portGroups = @(
@{ Name = 'HQ-SERVER-Linux'; VlanId = $BaseVlanId },
@{ Name = 'HQ-DMZ-Linux'; VlanId = $BaseVlanId + 1 },
@{ Name = 'HQ-CLIENT-Linux'; VlanId = $BaseVlanId + 2 },
@{ Name = 'INET-HQ-Linux'; VlanId = $BaseVlanId + 3 },
@{ Name = 'INET-BRANCH-Linux'; VlanId = $BaseVlanId + 4 },
@{ Name = 'HOME-Linux'; VlanId = $BaseVlanId + 5 },
@{ Name = 'BR-SERVER-Linux'; VlanId = $BaseVlanId + 6 },
@{ Name = '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)"
}