-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkhealth.ps1
33 lines (23 loc) · 1.2 KB
/
checkhealth.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Import Module for WebApps
import-module .\webapps.psm1 -Force
#Set Parameter
$secpasswd = ConvertTo-SecureString "emailaccountpassword" -AsPlainText -Force
$emailcredential = New-Object System.Management.Automation.PSCredential ("emailaccountusername", $secpasswd)
$armendpoint = "https://adminmanagement.local.azurestack.external"
$armpasswd = ConvertTo-SecureString "MyServiceAdminPassword" -AsPlainText -Force
$armcredential = New-Object System.Management.Automation.PSCredential ("serviceadmin@mydirectory.onmicrosoft.com", $armpasswd)
$location ="local"
$From = "EmailAddressSender"
$To = "EmailAddressReceipt"
$Subject = "WebApps Alert $location"
$SMTPServer = "mailserver"
$SMTPPort = "587"
#Query Status
$Servers=Get-AzsWebAppStatus -location $location -armendpoint $armendpoint -armcredentials $armcredential
Foreach ($server in $servers){
$servername = $server.name
If ($Server.Status-ne "Ready"){
#Send Alert Email
$Body = "An Error was detected with your WebApp RP installation on $location. Please check the Server $servername the Azure Stack Admin Portal"
Send-MailMessage -From $From -to $To -Subject $Subject -Body $Body -SmtpServer $SMTPServer -port $SMTPPort -Credential $emailcredential -UseSsl
}}