60 lines
1.2 KiB
PowerShell
60 lines
1.2 KiB
PowerShell
# Path INI-Datei
|
|
$iniPath = "C:\EDP\ELP\ELP.ini"
|
|
|
|
# Print menue
|
|
Write-Host "Bitte wählen Sie den Zielserver aus:`n"
|
|
Write-Host "1 = 192.168.112.10 (ELW)"
|
|
Write-Host "2 = 172.20.2.24 (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, 2, 3 oder 9)"
|
|
|
|
# select IP from userinput
|
|
switch ($wahl)
|
|
{
|
|
"1"
|
|
{
|
|
$neueIP = "192.168.112.10"
|
|
}
|
|
"2"
|
|
{
|
|
$neueIP = "172.20.2.24"
|
|
}
|
|
"3"
|
|
{
|
|
$neueIP = "edp-schulung.drk-spa.de"
|
|
}
|
|
"9"
|
|
{
|
|
$neueIP = "127.0.0.1"
|
|
}
|
|
Default
|
|
{
|
|
Write-Host "Ungültige 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 "`nDie Host-IP wurde erfolgreich auf '$neueIP' geändert." -ForegroundColor Green
|
|
}
|
|
else
|
|
{
|
|
#Print Errer 404
|
|
Write-Host "Die Datei '$iniPath' wurde nicht gefunden." -ForegroundColor Red
|
|
}
|