From 7ad10aa11e1c5a90d2ff910aca87ad2514549ca3 Mon Sep 17 00:00:00 2001 From: Pakobbix Date: Mon, 13 Mar 2023 15:33:22 +0000 Subject: [PATCH] Fixed folder creation, fixed text enter, added possible user list. --- WireWin.ps1 | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/WireWin.ps1 b/WireWin.ps1 index 7a7b2e6..22a1687 100644 --- a/WireWin.ps1 +++ b/WireWin.ps1 @@ -11,18 +11,37 @@ if (!(Get-Command choco.exe -ErrorAction SilentlyContinue)) { } # Installiere Wireguard mit chocolatey -choco install wireguard -y +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: -$config = Read-Host "Gebe hier die Wireguard Konfiguration ein: (Zweimal auf Enter drücken zum bestätigen)" +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 -$usertoadd = Read-Host "Gebe den Nutzernamen ein: (Zweimal auf Enter drücken zum bestätigen)" +$users = Get-ChildItem -Path "C:\Users" -Directory | Where-Object { $_.GetFileSystemInfos().Count -gt 0 } | ForEach-Object { $_.Name } +$possible_users = $users -join ", " -Add-LocalGroupMember -Group 'Netzwerkkonfigurations-Operatoren' -Member '$usertoadd' -Verbose \ No newline at end of file +$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 \ No newline at end of file