Code: Alles auswählen
$ErrorActionPreference = "SilentlyContinue"
$evt = new-object System.Diagnostics.EventLog("Application")
$evt.Source = "UrlWatchdog"
$infoevent = [System.Diagnostics.EventLogEntryType]::Information
$answer = "EmptyAnswer"
$answer = (new-object System.Net.WebClient).DownloadString("http://<Meine XBOX IP>:1026")
$res = ($answer -ne "EmptyAnswer")
if($answer -ne "EmptyAnswer"){
$evt.WriteEntry("Active XBOX360 found ... stopping Lights Out Service",$infoevent,100)
Stop-Service displayname "Lights Out Service"
} else {
$evt.WriteEntry("No active XBOX360 found ... starting Lights Out Service",$infoevent,100)
Start-Service displayname "Lights Out Service"
}
(Ich hab das ganze auch noch um Zwei Einträge im Eventlog erweitert)
Gruß, Dirk