54 lines
1.8 KiB
PowerShell
54 lines
1.8 KiB
PowerShell
# Auto-generated TAP adapter installation script
|
|
# Requires Administrator privileges
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# Check if running as Administrator
|
|
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
|
$isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
|
|
if (-not $isAdmin) {
|
|
Write-Host "ERROR: This script must be run as Administrator!" -ForegroundColor Red
|
|
Write-Host "Right-click PowerShell and select 'Run as Administrator'" -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Installing additional TAP adapters..." -ForegroundColor Cyan
|
|
|
|
$tapctlPath = "C:\Program Files\OpenVPN\bin\tapctl.exe"
|
|
|
|
if (-not (Test-Path $tapctlPath)) {
|
|
Write-Host "ERROR: OpenVPN not found at: $tapctlPath" -ForegroundColor Red
|
|
Write-Host "Please install OpenVPN from: https://openvpn.net/community-downloads/" -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
|
|
$existingCount = 10
|
|
$targetCount = 10
|
|
|
|
for ($i = ($existingCount + 1); $i -le $targetCount; $i++) {
|
|
Write-Host "Creating TAP adapter #$i..." -ForegroundColor Yellow
|
|
|
|
try {
|
|
& $tapctlPath create --name "OpenVPN-TAP-$i"
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host " ✓ Created OpenVPN-TAP-$i" -ForegroundColor Green
|
|
} else {
|
|
Write-Host " ⚠ Failed to create adapter (exit code: $LASTEXITCODE)" -ForegroundColor Red
|
|
}
|
|
} catch {
|
|
Write-Host " ✗ Error: $_" -ForegroundColor Red
|
|
}
|
|
|
|
Start-Sleep -Milliseconds 500
|
|
}
|
|
|
|
Write-Host "`n✓ TAP adapter installation complete!" -ForegroundColor Green
|
|
Write-Host "Verifying installation..." -ForegroundColor Cyan
|
|
|
|
$finalCount = (Get-NetAdapter | Where-Object { $_.InterfaceDescription -like "*TAP*" }).Count
|
|
Write-Host "Total TAP adapters now: $finalCount" -ForegroundColor Cyan
|
|
|
|
exit 0
|