# Autor: Florian Späth
# v1.0.0
$racadmpath = "C:\Program Files\Dell\SysMgt\rac5"
$Password = "Ob>Q%T\;Cf(9\+T+-7lNQl*i*)(3;Egl"
$servername = '192.168.178.4'
$username = 'spaethf'
$plinkpath = 'C:\Programme\PuTTY\'

function main{
$whattodo = Read-Host "Was moechtest du tun? `n1 = R710 Server starten, 2 = R710 Server stoppen `n3 = R710 Systemzustand `n4 = Tap MEG, 5 = Tap ITM `n6 = EXIT"
if ($whattodo -eq "1") {
    cd $racadmpath
    .\racadm.exe -r spaeth-bayern.de:5005 -u root -p "kt}y/6ZHF~.@" serveraction powerup
    Write-Host "Server startet! Dauer: ca. 5 min."
	main
}elseif($whattodo -eq "2"){
    $confirmation = Read-Host "Sind alle VM ausgeschaltet? j/n"
    if ($confirmation -eq "j") {
        cd $racadmpath
        .\racadm.exe -r spaeth-bayern.de:5005 -u root -p "kt}y/6ZHF~.@" serveraction powerdown
        Write-Host "Server stoppt!"
	main
    }else{
        Write-Host "Schalte die VM über RDP aus"
	main
    }
}elseif($whattodo -eq "3"){
    Write-host "Systeminfo:"
    cd $racadmpath
    .\racadm.exe -r spaeth-bayern.de:5005 -u root -p "kt}y/6ZHF~.@" getsysinfo
	main
}elseif ($whattodo -eq "4") {
    $command = 'python tap_meg.py'
    #Execute SSH command
    echo y | &($plinkpath + "plink.exe") -pw $password $username@$servername $command
	main
}elseif ($whattodo -eq "5") {
    $command = 'python tap_itm.py'
    #Execute SSH command
    echo y | &($plinkpath + "plink.exe") -pw $password $username@$servername $command
	main
}elseif ($whattodo -eq "6") {
    exit
}
}
main