Created
December 6, 2018 01:24
-
-
Save n3wc/b26c74230548671f8cbdac5a2fcf9654 to your computer and use it in GitHub Desktop.
fo76.ps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Username = "user.name"; #don't include @gmail.com | |
$Password = "I<3bananas!"; | |
function Get-TimeStamp {return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)} | |
function Send-ToEmail([string]$email){ | |
$message = new-object Net.Mail.MailMessage; | |
$message.From = "user.name@gmail.com"; | |
$message.To.Add($email); | |
$message.Subject = "FO76 Online!"; | |
$message.Body = "Fallout 76 servers are live!"; | |
$smtp = new-object Net.Mail.SmtpClient("smtp.gmail.com", "587"); | |
$smtp.EnableSSL = $true; | |
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password); | |
$smtp.send($message); | |
} | |
#check server status every 5 minutes | |
while(1 -eq 1){ | |
# scrape server status from API | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
$data = Invoke-WebRequest -Uri "https://api.bethesda.net/status/ext-server-status?product_id=8" | Select Content | |
if($data -CMatch "DOWN"){ | |
#do nothing | |
#Send-ToEmail -email "user.name@gmail.com"; | |
Write-Host "$(Get-TimeStamp) DOWN" | |
}else{ | |
Write-Host "UP" | |
Send-ToEmail -email "user.name@gmail.com"; | |
[Environment]::Exit(1) | |
} | |
Start-Sleep -Seconds 60 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment