Cant give you the hole script but for a good start
1. Login like:
Write-Host $url #url is https://ip_name_CC//brightmail/viewLogin.do
[net.httpWebRequest] $req = [net.webRequest]::create($url)
$req.method = "GET"
$req.Accept = "text/html"
$req.AllowAutoRedirect = $true
...
$match=$result | Select-String '(name="lastlogin" value="*.*")'
#...some more replacing, spliting ...
Write-Host $url2 #url2 is .../brightmail/login.do
Write-Host $postData #postData is username=xxx&password=xxx...
[net.httpWebRequest] $req2 = [net.webRequest]::create($url2)
$buffer = [text.encoding]::ascii.getbytes($postData)
$req2.method = "POST"
$req2.Accept = "text/html"
$req2.CookieContainer = $CookieContainer
$req2.ContentType = "application/x-www-form-urlencoded"
$req2.ContentLength = $buffer.length
# ...some more getResponse, IO.StreamReading
2. Checking the queues, eg delivery queue:
#as above but dont forget to use the cookie
Write-Host .../brightmail/status/messageQueue/MessageQueueFlow$list.flo
#get the IO.Stream and split it like "[INT]$count = $matches.Matches[$service.Result].value.Split('>*<')[2]"
3. Check if the value is above your limit to alert:
if ($count -gt $ServiceError)...
Write-EventLog -LogName Application -Source $ServiceSource -EntryType Error -EventId $ErrorEventID -Message ...
Regards
Thomas