Skip to content

Commit 5f63e17

Browse files
authored
Merge pull request #90 from dominikzorgnotti/maclearning-gt-66
vSphere 7.0 updates
2 parents d0d35de + 2a4b55e commit 5f63e17

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

powershell/MacLearn.ps1

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
[Parameter(Mandatory=$true)][String[]]$DVPortgroupName
2121
)
2222

23+
$minSwitchVersion = "6.6.0"
24+
2325
foreach ($dvpgname in $DVPortgroupName) {
2426
$dvpg = Get-VDPortgroup -Name $dvpgname -ErrorAction SilentlyContinue
2527
$switchVersion = ($dvpg | Get-VDSwitch).Version
26-
if($dvpg -and $switchVersion -eq "6.6.0") {
28+
if($dvpg -and [version]$switchVersion -ge [version]$minSwitchVersion) {
2729
$securityPolicy = $dvpg.ExtensionData.Config.DefaultPortConfig.SecurityPolicy
2830
$macMgmtPolicy = $dvpg.ExtensionData.Config.DefaultPortConfig.MacManagementPolicy
2931

@@ -41,7 +43,7 @@
4143
}
4244
$securityPolicyResults
4345
} else {
44-
Write-Host -ForegroundColor Red "Unable to find DVPortgroup $dvpgname or VDS is not running 6.6.0"
46+
Write-Host -ForegroundColor Red "Unable to find DVPortgroup $dvpgname or VDS is not running $minSwitchVersion or later"
4547
break
4648
}
4749
}
@@ -88,11 +90,13 @@ Function Set-MacLearn {
8890
[Parameter(Mandatory=$false)][Int]$Limit=4096,
8991
[Parameter(Mandatory=$false)][String]$LimitPolicy="DROP"
9092
)
93+
94+
$minSwitchVersion = "6.6.0"
9195

9296
foreach ($dvpgname in $DVPortgroupName) {
9397
$dvpg = Get-VDPortgroup -Name $dvpgname -ErrorAction SilentlyContinue
9498
$switchVersion = ($dvpg | Get-VDSwitch).Version
95-
if($dvpg -and $switchVersion -eq "6.6.0") {
99+
if($dvpg -and [version]$switchVersion -ge [version]$minSwitchVersion) {
96100
$originalSecurityPolicy = $dvpg.ExtensionData.Config.DefaultPortConfig.SecurityPolicy
97101

98102
$spec = New-Object VMware.Vim.DVPortgroupConfigSpec
@@ -129,8 +133,8 @@ Function Set-MacLearn {
129133
$task1 | Wait-Task | Out-Null
130134
}
131135
} else {
132-
Write-Host -ForegroundColor Red "Unable to find DVPortgroup $dvpgname or VDS is not running 6.6.0"
136+
Write-Host -ForegroundColor Red "Unable to find DVPortgroup $dvpgname or VDS is not running $minSwitchVersion or later"
133137
break
134138
}
135139
}
136-
}
140+
}

0 commit comments

Comments
 (0)