IT STORYs
Exchange White Space 자동 메일 보내기 스크립트 본문
Exchange white space 에 대한 이해는 아래 스크린샷으로 대체 합니다.
스크린트 내용
당연한 이야기지만 Exchange Powsehell 에서 작동합니다
-----------------------------------------------------------------------------------------------------------------------------
del E:\Script_Report\All_WhiteSpace.csv
Get-MailboxDatabase DatabaseName101 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName102 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName103 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName104 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName201 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName202 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName203 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName204 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName301 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName302 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName303 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName304 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName401 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName402 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName403 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName404 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName501 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName502 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName503 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName504 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName505 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName506 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName507 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName508 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName509 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName510 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName511 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName601 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName602 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName603 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName604 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName605 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName606 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName607 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName608 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName609 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName610 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName611 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName701 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName702 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName703 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName707 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName708 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName709 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName801 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName802 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName803 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName807 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName808 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase DatabaseName809 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase INDDB01 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase INDDB02 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase CFPDB01 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase CFPDB02 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase EGYDB01 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase EGYDB02 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
Get-MailboxDatabase EGYDB03 -Status | select Name, @{Name='Users'; expression = { (Get-Mailbox -ResultSize unlimited -Database $_.Identity | Measure-Object).Count} }, databasesize, AvailableNewMailboxSpace | Export-Csv -path 'E:\Script_Report\All_WhiteSpace.csv' -Encoding UTF8 -Append
###############################################################################
###########Define Variables########
$fromaddress = "khlee@gmail.com"
$toaddress = "khlee@gmail.com"
#$bccaddress = "khlee@gmail.com"
#$CCaddress = "khlee@gmail.com"
$Subject = "Exchange WhiteSpace Report"
#$body = get-content .\content.htm
$attachment = "E:\Script_Report\All_WhiteSpace.csv"
$smtpserver = "MSTP Server DNS or IP"
####################################
$message = new-object System.Net.Mail.MailMessage
$message.From = $fromaddress
$message.To.Add($toaddress)
#$message.CC.Add($CCaddress)
#$message.Bcc.Add($bccaddress)
#$message.IsBodyHtml = $True
$message.Subject = $Subject
$attach = new-object Net.Mail.Attachment($attachment)
$message.Attachments.Add($attach)
#$message.body = $body
$smtp = new-object Net.Mail.SmtpClient($smtpserver)
$smtp.Send($message)
#################################################################################