2010-02-01 31 views
0

我們讓我們的服務器人員在Exchange上設置了一些東西,以便對於特定的電子郵件地址,發送給它的任何附件都將被轉儲到文件服務器上的某個位置。如何從我的應用程序監視Exchange 2003事件服務?

Exchange事件服務控制這種行爲,但似乎這種特定的服務經常失敗。我不知道爲什麼 - 我沒有訪問Exchange服務器,並且由不同國家的團隊運行。

是否有可能以編程方式監視此交換服務,以便在出現故障時提醒用戶?我知道「正確」的解決方案是讓Exchange團隊處理這個問題,但由於時區差異(以及他們的大量工作量),我真的需要從我的最終處理它。

你可以用WebDav做這種事嗎?

回答

0

您可以使用下面的PowerShell腳本:

# Getting status of Exchange Services and look for anything that's "stopped" 
$ServiceStatus = get-service MSExch* | where-object {$_.Status -eq "stopped"} 

# Convert Result to String 
$ServiceStatusText = $ServiceStatus | fl | Out-String 

# If $ServiceStatus <> $null then send notification 
If ($ServiceStatus -ne $null) 
{ 
###Exchange Server Values 
$FromAddress = "[email protected]_DOMAIN.local" 
$ToAddress = "[email protected]_DOMAIN.com" 
$MessageSubject = "CRITICAL: An exchange service is has stopped" 
$MessageBody = "One or more Exchange services has stopped running or crashed. Please check the server ASAP for possible issues`n" 
$MessageBody = $MessageBody + $ServiceStatusText 

$SendingServer = "msexch02.pnlab.local" 

###Create the mail message and add the statistics text file as an attachment 
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody 

###Send the message 
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer 
$SMTPClient.Send($SMTPMessage) 
} 

# Else don't do anything and exit 
Else 
    { 
    $null 
    } 
相關問題