Posted on:
Categories: SharePoint;PowerShell


You need to increase the maximum file size of files that can be uploaded to SharePoint. By default, SharePoint allows a maximum file size of 250MB.


SharePoint required 3 changes in order to allow larger files to be uploaded:

  • WebApplication.MaximumFileSize, SharePoint setting which specifies how large of a file SharePoint will accept in MB. The maximum is 2047MB.
  • Web.config executionTimeout, IIS setting which specifies how long in seconds that a single request can execute.
  • Web.config maxRequestLength, IIS setting which specifies how large of a buffer in KB that IIS allows for a single request.

This following script will set all the values mentioned above. Furthermore, the Web.config changes are applied through SharePoint using the SPWebConfigModification Object which will apply the Web.config modifications in a supported manner.

# Name:               Enable-SPLargeFileUpload.ps1  
# Description:         This script will enable large file upload on a Web Application
# Usage:            Run the function with the required parameters
# By:                 Ivan Josipovic,  

Function Enable-SPLargeFileUpload ($WebApplication, $FileSize, $ExecutionTimeout, $MaxRequestLength) {
 $webapp = Get-SPWebApplication $webApplication
 Function CreateModification ($path, $name, $owner, $value){
  $configMod1 = New-Object "Microsoft.SharePoint.Administration.SPWebConfigModification";
  $configMod1.Path = $path;
  $configMod1.Name = $name;
  $configMod1.Sequence = 0;
  $configMod1.Type = 1;
  $configMod1.Owner = $owner;
  $configMod1.Value = $value;

 CreateModification -Path "/configuration/system.web/httpRuntime" -Name "executionTimeout" -Owner "LargeFileUpload" -Value $ExecutionTimeout;
 CreateModification -Path "/configuration/system.web/httpRuntime" -Name "maxRequestLength" -Owner "LargeFileUpload" -Value $MaxRequestLength;
 $webapp.MaximumFileSize = $FileSize;

#Enable-SPLargeFileUpload -WebApplication -FileSize 2047 -ExecutionTimeout 18000 -MaxRequestLength 2097152;