Tuesday, 23 January 2018

SharePoint Online Automation: Increase SharePoint Storage Quota in SharePoint Online Using PowerShell

In this article, we will learn about How to Increase SharePoint Storage Quota in SharePoint Online Using PowerShell. In last few of articles I have been demonstrated about below topics:

Kindly check the above articles to understand the requirement of business and solve the issue programmatically.
This demonstration will be applied to SharePoint Online, Office 365 Admin, and Office 365 Small Business Admin
As we know When a site collection is created in SharePoint online, we must specify a storage quota. This site size value must be between 100 MB and 100 GB. We will discuss more about site collection quota and usage in next coming article.
SharePoint online Site Collection Quota is allocated a quantity of storage that's based on your number of users. The storage is available to all site collections in the tenant and serves as a central pool from which everyone can draw. Site quota can be updated and modify as per requirement. If you are a Global admin for Office 365 tenant or Site collection administrator you will have access to do it.
Example: If you are managing a site collection, it will be easy to check site quota and increase the same, if working in the organization as SharePoint online Administrator where more than 1000+ site collection exists and on daily basis, we keep getting the request to update site collection quota. This is something where we need more attention and human effort to work on the same request.
Below are the steps to perform the above activity step by step with the screenshot:
Open PowerShell ISE with Admin rights and copy below script
As mentioned in last articles, we always need to do changes to the defined variable as per your requirement. Here we need to update below details,

  • $UserName = User Name of your Office 365 account – Line 7
  • $Password = Your Account password – Line 8
  • $Site URL - Site URL of Office 365 SharePoint Online where you increase site quota – Line 17
  • Read-Host "Enter the SharePoint Online Tenant" – Line 3
  • Tenant URL
  • $Quota=Read-Host "Enter the Storage Quota (1 GB) to be increased [in GB]: - Line 18

See below screenshot for more details

Import-Module Microsoft.Online.SharePoint.Powershell
Write-Host "This script is to set Storage Quota" -f DarkGreen
Read-Host "Enter the SharePoint Online Tenant"
   
   Write-Host "Connecting to SharePoint Online Tenant"
   
   $UserName="Your Account Name"  
   $Password ='Password'
   #Setup Credentials to connect
   $Credentials = New-Object System.Management.Automation.PSCredential($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))  
 
   Connect-SPOService -Url "Office 365 Tenant" -Credential $Credentials
   Write-Host "Your Tenant is connected"
   $SiteUrl=Read-Host "Enter the site Collection URL to which you want to increase storage quota"
   [int]$Quota=Read-Host "Enter the Storage Quota (1 GB)to be increased [in GB]:"
   $siteUrlDetail= Get-SPOSite $SiteUrl -Detailed -Limit all
   [int]$CurrentStorage= $siteUrlDetail.StorageQuota
       if ($Quota -eq 5)
       {
       Write-Host "Current Storage Quota is: $([MATH]::Round($CurrentStorage/1024,2)) GB"
       [int]$NewStorage = $Quota * 1024
       $StorageToIncrease = $CurrentStorage + $NewStorage
       Set-SPOSite -Identity $SiteUrl -StorageQuota $StorageToIncrease
       $NewSite = Get-SPOSite $SiteUrl -Detailed
       $NewQuota = [MATH]::Round($NewSite.StorageQuota/1024,2)
       Write-Host "New Storage Quota is : $NewQuota GB"
       }
       else
       {
           Write-Host "You have entered the wrong value.As per Defined policy, Please enter 1 GB only for Sites" -f Red
       }
  
  • Once you have done with changes or modification of defined variables, click on F5 and wait for below screen to come up asking you to enter Office 365 URL, see below screenshot:


  • After the site is getting connected, it will prompt for Site collection where you want to increase site Quota.



  • Later this entry, PowerShell script will start action to check existing site quota and it will match with defined standard quota if Site quota is exceeded than standard limitation it will prompt to enter the site quota. 
  • Now you can see, you site quota has been changed and it will show the current quota size of site collection as well.

No comments:

Post a Comment