Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# -------------------------------------------------------------------------------
# Script: Get-MessageSizeLimits.ps1
# Author: Chris Brown
# Date: 28/04/2011
# -------------------------------------------------------------------------------
# Import the Exchange Snap-ins
if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue) -eq $null) {
Write-Verbose "Exchange 2010 snapin is not loaded. Loading it now."
try { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010; Write-Verbose "Loaded Exchange 2010 snapin" }
catch { Write-Error "Could not load Exchange 2010 snapins!"; }
}
# Reset the variable holding the data, just in case.
$limits = @()
# Enumerate through all the send connectors in the Organization
Get-SendConnector | % {
$limit = "" | Select-Object "Type","Server","Name","Limit"
$limit.Type = "SendConnector"
$limit.Server = "Organization"
$limit.Name = $_.Name
$limit.Limit = $_.MaxMessageSize
$limits += $limit
}
# Enumerate through all the receive connectors in the Organization
Get-ReceiveConnector | % {
$limit = "" | Select-Object "Type","Server","Name","Limit"
$limit.Type = "ReceiveConnector"
$limit.Server = $_.Server
$limit.Name = $_.Name
$limit.Limit = $_.MaxMessageSize
$limits += $limit
}
# Get the global transport settings
$tc = Get-TransportConfig
$limit = "" | Select-Object "Type","Server","Name","Limit"
$limit.Type = "TransportConfig"
$limit.Server = "Organization"
$limit.Name = "Maximum Receive Size"
$limit.Limit = $tc.MaxReceiveSize
$limits += $limit
$limit = "" | Select-Object "Type","Server","Name","Limit"
$limit.Type = "TransportConfig"
$limit.Server = "Organization"
$limit.Name = "Maximum Send Size"
$limit.Limit = $tc.MaxSendSize
$limits += $limit
# Now let's process the data and output something pretty
# Get all objects with the smallest limits
$smallest = $limits | Sort-Object Limit | Select-Object -First 1
$allSmallest = $limits | Where {$_.Limit -eq ($smallest).Limit }
Clear-Host
Write-Host "`nThe maximum size of any email that can fully traverse your Exchange 2010 Organization is $($smallest.Limit)"
Write-Host "This is because of the following object(s):"
$allSmallest | Format-Table -AutoSize -Wrap
Write-Host "`nYou should raise the maximum size of message allowed across the object(s) above if you are having mail"
Write-Host "delivery issues of large items. Note that this script will not check non-exchange transports such as"
Write-Host "AntiVirus and Smart-hosts."
Write-Host "Raise the size of message allowed across Send Connectors with Set-SendConnector -MaxMessageSize"
Write-Host "Raise the size of message allowed across Receive Connectors with Set-ReceiveConnector -MaxMessageSize"
Write-Host "Raise the size of message allowed across the global transport config with Set-TransportConfig -MaxReceiveSize"
Write-Host "`t`t`t`tand Set-TransportConfig -MaxSendSize`n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment