Kurumsal yapılara kurmuş olduğumuz Exchange Server bilgilerini Donanım, DAG, kullanıcı bazlı olarak raporlanması, hizmet verdiğimiz firmalar tarafından istenebilir. Bu yazımda sahada ve büyük yapılarda Exchange Adminlerinin oldukça işine yarayacağını düşündüğüm raporlama adımlarını ve raporlama Scriptlerini sizler ile paylaşacağım.

Öncelikle Get-ExchangeEnvironmentReport.ps1 scripti ile başlayalım. Aşağıda ki link üzerinden Script’ i download edebilirsiniz.

http://gallery.technet.microsoft.com/exchange/Generate-Exchange-2388e7c9

Script Exchange Server 2010 ve Exchange Server 2013 üzerinde sorunsuz çalışmaktadır. Script’i download ettikten sonra c:\ dizini altına kopyalıyoruz. Daha sonra Exchange Server PowerShell üzerinde c: dizinine düşüp aşağıda belirttiğim komutlar sayesinde .html formatında rapor olarak kayıt edebiliriz.

 

.\Get-ExchangeEnvironmentReport.ps1 -HTMLReport c:\report.html

report1

C: altına report.html oluştu içeriğine bakalım.

report2

Rapor üzerinde;

  • Total Server
  • Total Mailbox
  • Total Roles
  • Exchange Server Version
  • Yüklü olan roller
  • İşletim Sistemi Versiyonu
  • İşletim Sistemi Service Pack durumu
  • Server İsmi, Database İsmi
  • Av. Mailbox Size
  • DataBase Size
  • Database WhiteSpace
  • Database Free Disk Alanı
  • Log Disk Free gibi bir çok bilgiye ulaşabiliyoruz.

Raporu mail olarak göndermek istersek;

.\Get-ExchangeEnvironmentReport  -HTMLReport c:\report.html -SendMail:$true -MailFrom:reports@Get-ExchangeServer.com -MailTo:ufuk@ Get-ExchangeServer.com -MailServer:smtp.Get-ExchangeServer.com

Rapor için Schedule oluşturmak istersek;

.\Get-ExchangeEnvironmentReport  -HTMLReport c:\report.html -SendMail:$true -MailFrom:reports@Get-ExchangeServer.com -MailTo:ufuk@ Get-ExchangeServer.com -MailServer:smtp. Get-ExchangeServer.com -ScheduleAs: Get-ExchangeServer\Ufuk

Mailbox Size Report

Aşağıda belirttiğim Script’ i bir txt dosyasına kopyalayın ve Get-MailboxReport.ps1 olarak kayıt edin.

<#

.SYNOPSIS

Get-MailboxReport.ps1 – Mailbox report generation script.

 

.DESCRIPTION

Generates a report of useful information for

the specified server, database, mailbox or list of mailboxes.

Use only one parameter at a time depending on the scope of

your mailbox report.

 

.OUTPUTS

Single mailbox reports are output to the console, while all other

reports are output to a CSV file.

 

.PARAMETER all

Generates a report for all mailboxes in the organization.

 

.PARAMETER server

Generates a report for all mailboxes on the specified server.

 

.PARAMETER database

Generates a report for all mailboxes on the specified database.

 

.PARAMETER file

Generates a report for mailbox names listed in the specified text file.

 

.PARAMETER mailbox

Generates a report only for the specified mailbox.

 

.PARAMETER filename

(Optional) Specifies the CSV file name to be used for the report.

If no file name specificed then a unique file name is generated by the script.

 

.EXAMPLE

.\Get-MailboxReport.ps1 -database HO-MB-01

Returns a report with the mailbox statistics for all mailbox users in

database HO-MB-01

 

.EXAMPLE

.\Get-MailboxReport.ps1 -file .\users.txt

Returns a report with the mailbox statistics for all mailbox users in

the file users.txt. Text file should contain names in a format that

will work for Get-Mailbox, such as the display name, alias, or primary

SMTP address.

 

.EXAMPLE

.\Get-MailboxReport.ps1 -server ex2010-mb1

Generates a report with the mailbox statisitcs for all mailbox users

on ex2010-mb1

 

.EXAMPLE

.\Get-MailboxReport.ps1 -server ex2010-mb1 -filename ex2010-mb1.csv

Generates a report with the mailbox statisitcs for all mailbox users

on ex2010-mb1, and uses the custom file name of ex2010-mb1.csv

 

Change Log

V1.0, 2/2/2012 – Initial version

V1.1, 27/2/2012 – Improved recipient scope settings, exception handling, and custom file name parameter.

#>

 

 

param(

[Parameter(ParameterSetName='database')] [string]$database,

[Parameter(ParameterSetName='file')] [string]$file,

[Parameter(ParameterSetName='server')] [string]$server,

[Parameter(ParameterSetName='mailbox')] [string]$mailbox,

[Parameter(ParameterSetName='all')] [switch]$all,

[string]$filename

)

 

#……………………………..

# Variables

#……………………………..

 

$ErrorActionPreference = “SilentlyContinue”

$WarningPreference = “SilentlyContinue”

$report = @()

 

 

#Set recipient scope

$2007snapin = Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.Admin

if ($2007snapin)

{

$AdminSessionADSettings.ViewEntireForest = 1

}

else

{

$2010snapin = Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010

if ($2010snapin)

{

Set-ADServerSettings -ViewEntireForest $true

}

}

 

 

#If no filename specified, generate report file name with random strings for uniqueness

#Thanks to @proxb and @chrisbrownie for the help with random string generation

 

if ($filename)

{

$reportfile = $filename

}

else

{

$timestamp = Get-Date -UFormat %Y%m%d-%H%M

$random = -join(48..57+65..90+97..122 | ForEach-Object {[char]$_} | Get-Random -Count 6)

$reportfile = “MailboxReport-$timestamp-$random.csv”

}

 

 

#……………………………..

# Script

#……………………………..

 

#Add dependencies

Import-Module ActiveDirectory

 

#Get the mailbox list

 

Write-Host -ForegroundColor White “Collecting mailbox list”

 

if($all) { $mailboxes = @(Get-Mailbox -resultsize unlimited -IgnoreDefaultScope) }

 

if($server) { $mailboxes = @(Get-Mailbox -server $server -resultsize unlimited -IgnoreDefaultScope) }

 

if($database){ $mailboxes = @(Get-Mailbox -database $database -resultsize unlimited -IgnoreDefaultScope) }

 

if($file) {  $mailboxes = @(Get-Content $file | Get-Mailbox -resultsize unlimited) }

 

if($mailbox) { $mailboxes = @(Get-Mailbox $mailbox) }

 

#Get the report

 

Write-Host -ForegroundColor White “Collecting report data”

 

$mailboxcount = $mailboxes.count

$i = 0

 

#Loop through mailbox list and find the aged mailboxes

foreach ($mb in $mailboxes)

{

$i = $i + 1

$pct = $i/$mailboxcount * 100

Write-Progress -Activity “Collecting mailbox details” -Status “Processing mailbox $i of $mailboxcount – $mb” -PercentComplete $pct

 

$stats = $mb | Get-MailboxStatistics | Select-Object TotalItemSize,TotalDeletedItemSize,ItemCount,LastLogonTime,LastLoggedOnUserAccount

$lastlogon = $stats.LastLogonTime

 

#This is an aged mailbox, so we want some extra details about the account

$user = Get-User $mb

$aduser = Get-ADUser $mb.samaccountname -Properties Enabled,AccountExpirationDate

 

#Create a custom PS object to aggregate the data we’re interested in

$userObj = New-Object PSObject

$userObj | Add-Member NoteProperty -Name “DisplayName” -Value $mb.DisplayName

$userObj | Add-Member NoteProperty -Name “Title” -Value $user.Title

$userObj | Add-Member NoteProperty -Name “Department” -Value $user.Department

$userObj | Add-Member NoteProperty -Name “Office” -Value $user.Office

$userObj | Add-Member NoteProperty -Name “Enabled” -Value $aduser.Enabled

$userObj | Add-Member NoteProperty -Name “Expires” -Value $aduser.AccountExpirationDate

$userObj | Add-Member NoteProperty -Name “Last Mailbox Logon” -Value $lastlogon

$userObj | Add-Member NoteProperty -Name “Last Logon By” -Value $stats.LastLoggedOnUserAccount

$userObj | Add-Member NoteProperty -Name “Item Size (Mb)” -Value $stats.TotalItemSize.Value.ToMB()

$userObj | Add-Member NoteProperty -Name “Deleted Item Size (Mb)” -Value $stats.TotalDeletedItemSize.Value.ToMB()

$userObj | Add-Member NoteProperty -Name “Items” -Value $stats.ItemCount

$userObj | Add-Member NoteProperty -Name “Type” -Value $mb.RecipientTypeDetails

$userObj | Add-Member NoteProperty -Name “Server” -Value $mb.ServerName

$userObj | Add-Member NoteProperty -Name “Database” -Value $mb.Database

 

#Add the object to the report

$report = $report += $userObj

}

 

#Catch zero item results

$reportcount = $report.count

 

if ($reportcount -eq 0)

{

Write-Host -ForegroundColor Yellow “No mailboxes were found matching that criteria.”

}

else

{

#Output single mailbox report to console, otherwise output to CSV file

if ($mailbox)

{

$report | Format-List

}

else

{

$report | Export-Csv -Path $reportfile -NoTypeInformation

Write-Host -ForegroundColor White “Report written to $reportfile in current path.”

Get-Item $reportfile

}

}

Get-Help .\Get-MailboxReport.ps1 yazarak kullanabileceğimiz komut listesine ulaşabiliriz.

SYNOPSIS

Get-MailboxReport.ps1 – Mailbox report generation script.

SYNTAX

  • Get-MailboxReport.ps1 [-database ] []
  • Get-MailboxReport.ps1 [-file ] []
  • Get-MailboxReport.ps1 [-server ] []
  • Get-MailboxReport.ps1 [-mailbox ] []
  • Get-MailboxReport.ps1 [-all] []

report3

 

.\Get-MailboxReport.ps1 -mailbox ufuk.tatlidil komutu ile kullanıcının bilgilerine ulaşıyoruz.

report4

Get-MailboxDatabase ile DB ismini öğreniyoruz.

.\Get-MailboxReport.ps1 -database “Mailbox Database 1088429004″ komutunu çalıştırarak .csv formatında raporumuzu alıyoruz.

report5

report6

Kullanıcı bilgilerini böylelikle Excel fortmatında alabiliyoruz.

report7

Message Size Limits

Organizasyonunuz bazında Messages Size liminiti öğrenmek için;

Get-TransportConfig | Select-Object MaxReceiveSize,MaxSendSize | fl

report8

Send Connector limiti için:

Get-SendConnector | Select-Object Name,MaxMessageSize

report9

Receive Connector limiti içim:

Get-ReceiveConnector | Select Server,Name,MaxMessageSize

report10