switched to notepad to create config file.
Powershell is still not powerfull enough to do text edit via shell (ssh terminal)
This commit is contained in:
parent
1f65e2536d
commit
701f586a32
33
WireWin.ps1
33
WireWin.ps1
@ -22,27 +22,36 @@ if (choco install wireguard -y) {
|
||||
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"
|
||||
New-Item -ItemType File -Path "C:\Program Files\WireGuard\Data\Configurations\Pyrexx.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 "")
|
||||
#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
|
||||
#Add-Content -Path "C:\Program Files\WireGuard\Data\Configurations\wg0.conf" -Value $config
|
||||
|
||||
# Öffnet die Config in Notepad
|
||||
notepad "C:\Program Files\WireGuard\Data\Configurations\Pyrexx.conf"
|
||||
|
||||
# Wait for Notepad to be closed
|
||||
$notepadProcess = Get-Process | Where-Object { $_.ProcessName -eq "notepad" }
|
||||
$notepadProcess.WaitForExit()
|
||||
|
||||
# Hier erstellen wir einen Registry Key mit dem Namen LimitedOperatorUI und dem wert 1
|
||||
reg add HKLM\Software\WireGuard /v LimitedOperatorUI /t REG_DWORD /d 1 /f
|
||||
|
||||
# Wir lassen Powershell hier die vorhandenen User auflisten, um diese dann in einem Menü anzeigen zu können, statt abzutippen
|
||||
$users = Get-ChildItem -Path "C:\Users" -Directory | Where-Object { $_.GetFileSystemInfos().Count -gt 0 } | ForEach-Object { $_.Name }
|
||||
$possible_users = $users -join ", "
|
||||
|
||||
Write-Host "Please choose a user:"
|
||||
Write-Host "Wähle den Nutzer aus, der der Netzwerkkonfigurations-Operatoren Gruppe hinzugefügt werden soll:"
|
||||
for ($i=0; $i -lt $users.Count; $i++) {
|
||||
Write-Host "$i. $($users[$i])"
|
||||
}
|
||||
@ -51,7 +60,7 @@ $choice = Read-Host "Enter the number of the user you want to choose (0-$($users
|
||||
|
||||
if ($choice -ge 0 -and $choice -lt $users.Count) {
|
||||
$selected_user = $users[$choice]
|
||||
Write-Host "You selected $($selected_user)"
|
||||
Write-Host "Der Nutzer $($selected_user) wird der Netzwerkkonfigurations-Operatoren Gruppe hinzugefügt"
|
||||
|
||||
# Use the selected user in the next command
|
||||
Add-LocalGroupMember -Group 'Netzwerkkonfigurations-Operatoren' -Member $selected_user -Verbose
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user