달력

5

« 2024/5 »

  • 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
  • 30
  • 31
PowerShell을 이용한 Exchange Server의 사서함 사용 현황 리포팅
응용하면 예약 작업 등의 기능을 통해 특정 PowerShell 실행 결과를 관리자에게 메일로 보내는 용도로 사용할 수 있겠다.
Exchange Server 2007에서 테스트 함.
실행 명령줄: PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\Bin\ExShell.psc1" -Command "C:\<파일 이름>.ps1"

$FromAddress="발신자 메일 주소"
$ToAddress="수신자 메일 주소"
$MessageSubject="사서함 사용 현황"
$MessageBody="ProhibitSend 또는 IssueWarning 상태의 사용자 사서함 현황"
$SendingServer="메일 서버 이름 또는 IP 주소"

$ProhibitSend="C:\ProhibitSend.txt"
$IssueWarning="C:\IssueWarning.txt"

Get-MailboxStatistics | Where { $_.StorageLimitStatus -eq "ProhibitSend" } | Sort-Object DisplayName | ft DisplayName, StorageLimitStatus, ItemCount > $ProhibitSend
Get-MailboxStatistics | Where { $_.StorageLimitStatus -eq "IssueWarning" } | Sort-Object DisplayName | ft DisplayName, StorageLimitStatus, ItemCount > $IssueWarning

$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody
$Attachment1 = new-object System.Net.Mail.Attachment $ProhibitSend
$SMTPMessage.Attachments.Add($Attachment1)
$Attachment2 = new-object System.Net.Mail.Attachment $IssueWarning
$SMTPMessage.Attachments.Add($Attachment2)
$SMTPClient=New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)
:
Posted by 커널64