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 versionMicrosoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.