Fixed folder creation, fixed text enter, added possible user list.
This commit is contained in:
parent
14a15aa0e4
commit
7ad10aa11e
27
WireWin.ps1
27
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
|
||||
$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
|
||||
Loading…
x
Reference in New Issue
Block a user