forked from joerod/powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exchange_db_status.ps1
21 lines (17 loc) · 964 Bytes
/
exchange_db_status.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
#stylesheet for html email
$style = "<style>BODY{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
$style = $style + "TD{border: 1px solid black; padding: 5px; }"
$style = $style + "</style>"
Function Get-DBstatus{
foreach($server in (@("mailboxserver1","mailboxserver2","mailboxserver3"))){
Get-MailboxDatabaseCopyStatus -Server $server |Select DatabaseName, Mailboxserver,Status |? {($_.Status -ne "Healthy") -and ($_.Status -ne "Mounted") -and ($_.Status -notlike "Seeding*") }
# Things to fix, ConvertTo-Html -Head $style
}
}
if($status -ne 0){
Send-MailMessage -To [email protected] `
-from [email protected] -Body (Get-DBstatus|Out-String) -subject "Error on Exchange DB" -smtpserver stmpmailbox -priority High
}