47 lines
1.8 KiB
PowerShell
47 lines
1.8 KiB
PowerShell
# Überprüfe ob powershellscripte ausgeführt werden dürfen
|
|
if ((Get-ExecutionPolicy) -eq "Restricted") {
|
|
Set-ExecutionPolicy RemoteSigned
|
|
}
|
|
|
|
# Überprüfe ob chocolatey installiert ist
|
|
if (!(Get-Command choco.exe -ErrorAction SilentlyContinue)) {
|
|
# Install Chocolatey
|
|
Set-ExecutionPolicy Bypass -Scope Process -Force
|
|
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
|
|
}
|
|
|
|
# Installiere Wireguard mit chocolatey
|
|
if (choco install wireguard -y) {
|
|
Write-Host "WireGuard wurde erfolgreich installiert."
|
|
} else {
|
|
Write-Host "WireGuard konnte nicht installiert werden."
|
|
exit
|
|
}
|
|
|
|
# Erstelle Verzeichnis zum speichern von WireGuard Konfigurationen
|
|
New-Item -ItemType Directory -Path "C:\Program Files\WireGuard\Data\Configurations\"
|
|
|
|
# Erstelle WireGuard Konfiguration
|
|
New-Item -ItemType File -Path "C:\Program Files\WireGuard\Data\Configurations\wg0.conf"
|
|
|
|
# Eingabe für die Wireguard Configuration:
|
|
Write-Host "Gebe hier die Wireguard Konfiguration ein: (Zweimal auf Enter drücken zum bestätigen)"
|
|
$config = ""
|
|
do {
|
|
$line = Read-Host
|
|
if ($line -ne "") {
|
|
$config += $line + "`n" # `n is the newline character
|
|
}
|
|
} until ($line -eq "")
|
|
|
|
# Füge die Konfiguration an die wg0.conf an
|
|
Add-Content -Path "C:\Program Files\WireGuard\Data\Configurations\wg0.conf" -Value $config
|
|
|
|
reg add HKLM\Software\WireGuard /v LimitedOperatorUI /t REG_DWORD /d 1 /f
|
|
|
|
$users = Get-ChildItem -Path "C:\Users" -Directory | Where-Object { $_.GetFileSystemInfos().Count -gt 0 } | ForEach-Object { $_.Name }
|
|
$possible_users = $users -join ", "
|
|
|
|
$usertoadd = Read-Host "Gebe den Nutzernamen ein: (Zweimal auf Enter drücken zum bestätigen) (Möglich sind: $possible_users)"
|
|
|
|
Add-LocalGroupMember -Group 'Netzwerkkonfigurations-Operatoren' -Member "$usertoadd" -Verbose |