Created
July 14, 2026 17:03
-
-
Save eugrus/b8ea2ce441d4416b30dfad4aeb8f2297 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param( | |
| [Parameter(Mandatory = $true, Position = 0)] | |
| [string]$OvpnFile, | |
| [Parameter(Mandatory = $true, Position = 1)] | |
| [string]$CaFile, | |
| [Parameter(Mandatory = $true, Position = 2)] | |
| [string]$CertFile, | |
| [Parameter(Mandatory = $true, Position = 3)] | |
| [string]$KeyFile, | |
| [Parameter(Position = 4)] | |
| [string]$OutputFile | |
| ) | |
| if (-not $OutputFile) { | |
| $directory = Split-Path $OvpnFile -Parent | |
| $basename = [System.IO.Path]::GetFileNameWithoutExtension($OvpnFile) | |
| $OutputFile = Join-Path $directory "${basename}_unified.ovpn" | |
| } | |
| # OVPN-Datei lesen und externe Zertifikatsreferenzen entfernen | |
| $ovpnContent = Get-Content $OvpnFile | Where-Object { | |
| $_ -notmatch '^ca\s+' -and | |
| $_ -notmatch '^cert\s+' -and | |
| $_ -notmatch '^key\s+' | |
| } | |
| # Zertifikate und Schlüssel laden | |
| $caContent = Get-Content $CaFile | |
| $certContent = Get-Content $CertFile | |
| $keyContent = Get-Content $KeyFile | |
| # Neue OVPN-Datei schreiben | |
| $ovpnContent | Set-Content $OutputFile | |
| Add-Content $OutputFile "`n<ca>" | |
| $caContent | Add-Content $OutputFile | |
| Add-Content $OutputFile "</ca>`n<cert>" | |
| $certContent | Add-Content $OutputFile | |
| Add-Content $OutputFile "</cert>`n<key>" | |
| $keyContent | Add-Content $OutputFile | |
| Add-Content $OutputFile "</key>" | |
| Write-Host "Unified .ovpn file generated:" | |
| Write-Host $OutputFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment