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,53 @@
<#
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:
WAN-Linux = BaseVlanId
INT-Linux = BaseVlanId + 1
DMZ-Linux = BaseVlanId + 2
VPN-Linux = BaseVlanId + 3
Example:
.\Create-PortGroups.ps1 -SwitchName vSwitch0
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$SwitchName,
[ValidateRange(1, 4094)]
[int]$BaseVlanId = 100
)
$ErrorActionPreference = 'Stop'
$switch = Get-VirtualSwitch -Name $SwitchName -ErrorAction Stop
$portGroups = @(
@{ Name = 'WAN-Linux'; VlanId = $BaseVlanId },
@{ Name = 'INT-Linux'; VlanId = $BaseVlanId + 1 },
@{ Name = 'DMZ-Linux'; VlanId = $BaseVlanId + 2 },
@{ Name = 'VPN-Linux'; 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)"
}