Powershell: Increase the max size limit for ActiveSync Properties/Metadata in you Web.Config

Scenario:  You need to increase the ActiveSync default message size limit from 10MB to a larger value.  By default the RequestFilteringLimit set in IIS is 30,000,000 bytes (approx. 28MB) so we will operate within the limitations of that setting, meaning you cannot go higher than 28MB unless you set that property to a higher value.  So lets be safe and set that value to 15MB on all multirole exchange 2013 servers.  We need to edit the web.config files in the following directories:
Client Access: 

%ExchangeInstallPath%FrontEndHttpProxySyncweb.config – maxRequestLength=”10240″ kilobytes

Mailbox

%ExchangeInstallPath%ClientAccessSyncweb.config – maxRequestLength=”10240″ kilobytes

%ExchangeInstallPath%ClientAccessSyncweb.config  – <add key=”MaxDocumentDataSize” value=”10240000″>  bytes
Script:  IISReset is not needed!

#variables
$servers = (Get-ExchangeServer).name
$MRL = "15360"  #15MB in KB
$MDDS = "15728640" #15MB in Bytes


$Servers | %{
#ClientAccess
    #MaxRequestLength
    $webConfig = "\$_c$Program FilesMicrosoftExchange ServerV15FrontEndHttpProxysyncweb.config" 
    $doc = new-object System.Xml.XmlDocument 
    $doc.Load($webConfig) 
    $doc.get_DocumentElement()."system.web".httpruntime.maxrequestlength = $MRL 
    #Save Document
    $doc.Save($webConfig) 

#Mailbox
    #MaxRequestLength
    $webConfig = "\$_c$Program FilesMicrosoftExchange ServerV15ClientAccessSyncweb.config" 
    $doc = new-object System.Xml.XmlDocument 
    $doc.Load($webConfig) 
    $doc.get_DocumentElement()."system.web".httpruntime.maxrequestlength = $MRL 
    #MaxDocumentDataSize
    $key = "MaxDocumentDataSize"
    $node = $doc.SelectSingleNode('configuration/appSettings/add[@key="' + $key + '"]') 
    $node.Attributes['value'].Value = $MDDS 
    #Save Document
    $doc.Save($webConfig) 
}

 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: