Forum Discussion
Setting Site's Maximum Storage Quota to Current Size + 50GB using PowerShell
I'm hoping someone can provide me a PowerShell script that will calculate the current size of a SharePoint site and set the Maximum storage quota of that site to the current size + 50GB.
As an example, if i have a site that's set to the default quota of 25600 GB and is currently taking up 100GB, how could i set the storage quota to 150GB (current size + 50 GB) using PS? I have hundreds of sites to change so using the GUI is not feasible.
1 Reply
- LeonPavesicSilver Contributor
Hi CLConsulting,
here is a PowerShell script to calculate the current size of a SharePoint site and the to set the Maximum storage quota of that site to the current size + 50GB (5000MB):
# Import the SharePoint Online PowerShell module Import-Module Microsoft.Online.SharePoint.PowerShell # Get the current site URL $SiteURL = "https://example.sharepoint.com/sites/Marketing" # Connect to SharePoint Online Connect-SPOService -Url $SiteURL # Get the current site collection $Site = Get-SPOSite -Identity $SiteURL -Detailed # Get the current site storage size in MB $CurrentStorage = $Site.StorageQuota # Calculate the new storage quota in MB $NewStorage = $CurrentStorage + 50000 # Set the new storage quota Set-SPOSite -Identity $SiteURL -StorageQuota $NewStorage # Write a confirmation message Write-Host "The storage quota for site '$SiteURL' has been set to $NewStorage MB."To use the script, simply replace the $SiteURL variable with the URL of the SharePoint site whose storage quota you want to increase. Then, run the script in PowerShell.
To increase the storage quota for hundreds of sites, you can use a PowerShell loop. For example, the following script will increase the storage quota for all sites in the current tenant by 50GB:
# Import the SharePoint Online PowerShell module Import-Module Microsoft.Online.SharePoint.PowerShell # Get all sites in the current tenant $Sites = Get-SPOSite -Limit All # Increase the storage quota for each site foreach ($Site in $Sites) { $CurrentStorage = $Site.StorageQuota $NewStorage = $CurrentStorage + 50000 Set-SPOSite -Identity $Site.URL -StorageQuota $NewStorage } # Write a confirmation message Write-Host "The storage quota for all sites in the current tenant has been increased by 50GB."
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic