Change upload file limit in specified Webapllication in SharePoint (PowerShell)

Introduction

This script could be used to change upload file limit in specified Webapllication in SharePoint.

Scenarios

Changing the upload file limits need several steps by using GUI. So a script will be better instead.

Script

This script contains one advanced function, Set-OSCMaximumFileSize. You can use this script in following ways:

Method 1:

  1. Download the script and open the script file with Notepad or any other script editors.
  2. Scroll down to the end of the script file, and then add the example command which you want to run.
  3. Save the file then run the script in PowerShell.

Method 2:

  1. Rename scriptname.ps1 to scriptname.psm1 (PowerShell Module file)
  2. Run Import-Module cmdlet to import this module file.
    Import-Module filepath\scriptname.psm1

Examples

Example 1: Set maximumfilesize to 30 MB on webapplication "http://win-lfseeatt8jr/"
Command: Set-OSCMaximumFileSize -WebApplication "http://win-lfseeatt8jr/" -Size 30
Screenshot:

 Here are some code snippets for your references.

PowerShell
Edit|Remove
#Get current maximumfilesize 
$CurrentSize = $webapp.MaximumFileSize 
#Get user's choice 
$result = GetChoice $CurrentSize $Size 
#If 'yes', then excute the following 
if($result -eq  0 ) 
{ 
  $webapp.MaximumFileSize = $Size 
  $webapp.update() 
  write-host "Set MaximumFileSize to $Size MB successfully. "} 
Else 
{ 
  write-warning "Action cancelled by user."}

Prerequisite

PowerShell

Windows Server 2008R2 or later version