HomelanIT

Enable Powershell scripts = Set-ExecutionPo​licy RemoteSigned

Email Alerts

$global:status = $null 
$count = 0 
$result = '' 
for ($count = 0; $count -lt 10; $count++) {      
$status = (get-service|where {$_.Name -eq 'AOS60$01'}|Select status).status      
if ($status -eq 'Running') { break }      
Start-Sleep 60 } 
if($status -eq 'Running') {$result = 'Started Successfully'} 
else {$result = 'Failed to start'} 
send-mailmessage -from "Server Alerts <italerts@domain.com>" -to 
"Server Alerts <italerts@domain.com>" -subject "AOS Service $result" -body "The AOS Service on SERVERNAME $result" -priority High -smtpServer EMAILSERVER

Back