EDP-Change-Server/Set-ELP-Host.ps1

74 lines
1.5 KiB
PowerShell

# Path INI-Datei
$iniPath = "C:\EDP\ELP\ELP.ini"
Write-Host "`n"
# Print menue
Write-Host "Bitte EDP-Server bestimmen:`n"
Write-Host "1 = 192.168.112.10 (ELW RK TUT 50/11-1)"
Write-Host "2 = 172.20.2.101 (DRK Spaichingen)"
#Write-Host "3 = edp-schulung.drk-spa.de (DRK Schulung)"
Write-Host "9 = 127.0.0.1 (Lokaler Server)"
Write-Host ""
# Read userinput
$wahl = Read-Host "Ihre Auswahl (1 bis 9)"
# select IP from userinput
switch ($wahl)
{
"1"
{
$neueIP = "192.168.112.10"
}
"2"
{
$neueIP = "172.20.2.101"
}
"3"
{
$neueIP = "edp-schulung.drk-spa.de"
}
"9"
{
$neueIP = "127.0.0.1"
}
Default
{
Write-Host "Unbekannte Auswahl. Vorgang abgebrochen." -ForegroundColor Red
exit
}
}
# read ini File
if (Test-Path $iniPath)
{
$iniInhalt = Get-Content $iniPath
# find line with "Hosts= and replace IP
$iniInhalt = $iniInhalt -replace '^Host=.*$', "Host=$neueIP"
# Write INI File
Set-Content -Path $iniPath -Value $iniInhalt
#Print promt
Write-Host "`nDer EDP-Server wurde auf '$neueIP' gewechselt." -ForegroundColor Green
}
else
{
#Print Errer 404
Write-Host "Die Datei '$iniPath' wurde nicht gefunden." -ForegroundColor Red
exit
}
$wahl = Read-Host "Soll EDP Einsatzleitplatz gestartet werden? (Y/n)"
if ($wahl -in @("Y", "y", "1", ""))
{
Write-Host "Starte EDP Einsatzleitplatz..."
Start-Process "C:\EDP\ELP\ELP.exe"
}
else
{
Write-Host "EDP wird nicht gestartet"
}