Last Update: Version 1.4, July 19th, 2019
Exchange Server 2013 and Exchange Server 2016 enforces certain message size limits when it comes to client messages. These limits are in-place so clients can’t generate excessive load on your Exchange environment. These limits are determined for various access methods in multiple web.config files on Exchange Client Access Servers as well as Mailbox Servers.
Sometimes you may have good reasons to increase those limits. For example, when migrating to Office 365 using a product like MigrationWiz, you may want to increase the limit for Exchange Web Service (EWS) requests to allow for migration of larger items. Another example is when you want to allow for bigger attachments in Outlook WebApp (OWA). On TechNet, there’s an article on how to reconfigure these limits. However, the process consists of editing multiple web.config files, replacing multiple values in the same file, and following this process on each Exchange 2013/2016 server in your environment. This is not only labor intensive and prone to error, but becomes tedious when you consider that each Cumulative Update will overwrite your web.config files.
But do not despair. To execute these changes for OWA and EWS, I have created a PowerShell script which will perform these tasks for you.
Using the script requires Exchange 2013. You need to provide the server name (default is local server) or AllServers to apply to all Exchange 2013/2016 servers in your environment. The script will modify the web.config remotely using the system share (e.g. C$), using the location of the Exchange installation, and uses IISRESET tool to restart IIS. It will create a backup of the web.config before modifying it.
- The script checks for running in elevated administrator mode when running against the local machine.
- Current version of the script requires Exchange Management Shell, to run Exchange cmdlets for checking installed roles a.o., as the web.config files which require editing depend on the installed roles.
- For OWA, add ~33% to the value you want to specify to compensate for encoding overhead.
- When connected to an Exchange server, the script processes the server hosting the EMS session last to prevent abortion caused by IIS reset.
- Script currently runs against Exchange 2013 or Exchange 2016.
The script Configure-ClientSizeLimits.ps1 uses the following syntax:
.\Configure-ClientSizeLimits.ps1 [-Server |-AllServers] [-OWA <size>] [-EWS <size>] [-EAS <size>] [-Reset] [-NoBackup]
A quick walk-through on the parameters and switches:
- Server specifies the server to configure. When omitted, it will configure the local server. This parameter is mutually exclusive with AllServers.
- AllServers switch specifies to configure all Exchange 2013 servers. This switch is mutually exclusive with Server.
- OWA configures the message size limit for Outlook Web Access. Value is in bytes.
- EWS configures the message size limit for Exchange Web Services. Value is in bytes.
- EAS configures the message size limit for Exchange ActiveSync. Value is in bytes.
- NoBackup tells the script not to make backup copies of modified web.config files.
- Reset switch specifies to perform an IISRESET against servers after reconfiguration of client-specific message size limits.
So, suppose you want to configure OWA, EWS and EAS client message size limits on the local Exchange server, you can use:
.\Configure-ClientSizeLimits.ps1 -OWA 15MB -EWS 15MB EAS 15MB
If you want to configure EWS limits for all servers, resetting IIS, you could use:
.\Configure-ClientSizeLimits.ps1 -AllServers -EWS 10240 -Reset
You can download the script from the TechNet Gallery here or GitHub.
Feedback is welcomed through the comments. If you got scripting suggestions or questions, do not hesitate using the contact form.
See TechNet Gallery page.
Pingback: Exchangepedia | Set message size limits in Exchange 2010/2013 and Exchange 2007
Pingback: Raise your Exchange Server EWS limits prior to starting your MigrationWiz project – Microsoft Exchange & Office 365
Pingback: Weekly IT Newsletter – June 22-26, 2015 | Just a Lync Guy
Hi, I’ve found your post very useful. At this moment I’m having something that could be fixed with your script. I’m having issues between Exchange 2010 and a Mac computer trying to send messages with attachment bigger than 9 MB and we receive an error each time we need to send a message. I tried to modify the web.config files manually but then the Mac computer wasn’t able to connect to the Exchange I had to revert the change.
Can I use your script on an Exchange 2010 server?
Pingback: 配置客户端指定消息大小限制 - Exchange中文站
Hi Michel, Awesome script, worked like a charm. Saved my day! Cheers 🙂
This is a great script; thank you.
Would there be any chance you could include the ability to update the ActiveSync settings at the same time as OWA and EWS?
This would be extremely helpful.
It’s on the to-do list, stay tuned
Any updates for EAS? Would be extremely useful at my current role.
Just updated – with EAS support
Thanks! I ended up having to roll my own, but this will be useful for the future!
Thanks for your script you save me a lot of time. And for ActiveSync any news?
This can be great!
Per v1.2, configuring EAS limits is possible as well.
Thanks I try it !
Can be useful to add in the script the backup of the existing .config files and also maybe show the existing value before confirm to change it.
Thanks for your script working well except for OWA if you already have a existing value the script add a other one and then OWA won’t restart.
Thanks for the feedback, will have a look
Found your script and figured this is a nice alternative to manually changing the thresholds like in the past. I am Running Exchange 2016 and just applied CU10, everything was working fine, then I ran your script, did an IISRESET and OWA/EAC access broke. Tested on a second DAG server and same result. Reverted to old web.config files and all is working again. Not sure if something has changes in the latest CU, but wanted to let you know.
Thanks for the heads-up!
Same simpton here, it doesn’t seem to work anymore, CU10.
What exactly did you change? Used it against Ex2016 CU10 without issue.
Very helpful script, but from my experience this breaks something in ews-api in DAG-environments.
Had to roll back the config-files. (Version 15.0 (Build 1395.4)
(Forgive me if I already submitted but I hit an error with wp so I’m not sure if it installs)
If i use a whatif it only applies to the backup portion of the script) is it possible to make it so whatif will effect the web.config modifications. (I have my own backup method so I was able to restore original settings)
Added WhatIf support in 1.3 just now; if you use it with Verbose, all the modifications will be shown without saving them.
Thanks! I”ll run it in my test environment. I see some issues with CU10 according to the comments, I’m still on CU7. Is the error with the changes due to the script or is it part of the CU that causes the error?