Sign In
 
 
Go Search
 
Zach Rosenfield's SharePoint Blog > Posts > Managing Bulk Site Collection Quotas in PowerShell
Managing Bulk Site Collection Quotas in PowerShell

It’s been too long since my last post! All the excitement over our first toolkit was appreciated… hope you are all anxiously awaiting the next release!

In the meantime, I saw a couple comments on the SharePoint blog regarding bulk Quota changes (inspired I’m sure by the Batch Site Manager tool).  While I can’t promise any new features to address this from the tools effort—I can show you how to do this today in PowerShell!  I’ve added three new functions to the functions.ps1 file in the Script LibraryDispose-SPSite, Get-SPQuota, and Set-SPQuota to help me achieve these goals.

First, I needed to add the Dispose-SPSite command so that we can ‘clean up’ directly in the pipeline whatever SPSite we are altering.  This function is rather small:

function global:Dispose-SPSite([Microsoft.SharePoint.SPSite]$Site){

  PROCESS{

       if($_){

         $_.Dispose();

       }else{

         $Site.Dispose();

       }

  }

}

The Get-SPQuota and Set-SPQuota take SPSite objects and get or set the Maximum Size and Warning Size.  These cmdlets are not capable of being piped to each other (as they both take SPSites), but you can use these functions to do quota changes like:

PS> Get-SPSite http://localhost | Set-SPQuota -MaxSize 5000000 -WarnSize 3000000 -PassThru -NoRefresh | Dispose-SPSite

PS> Get-SPSite http://localhost | Get-SPQuota

 

QuotaID                     : 34643

StorageMaximumLevel         : 5000000

InvitedUserMaximumLevel     : 0

StorageWarningLevel         : 3000000

UpgradedPersistedProperties :

 

Alternatively, the same goal with:

PS> Set-SPQuota –site http://localhost –MaxSize 5000000 –WarnSize 3000000 –PassThru | Dispose-SPSite

Or set quotas in bulk like:

Get-SPWebApplication | Where {$_.Name -eq "SharePoint - 80" }|%{$_.Sites} | Where{ $_.Owner -eq "DOMAIN\foo" } | Set-SPQuota –MaxSize 500000 –PassThru | Dispose-SPSite

The full syntax is:

Get-SPQuota -Site <SPSite>

Set-SPQuota -Site <SPSite> [-MaxSize <bytes> -WarnSize <bytes> -NoRefresh –PassThru]

Dispose-SPSite -Site <SPSite>

*Note: That these functions all use the SPSite object—which means your user account must have access to the site collection.  In a future post I’ll explain how to use the SPSiteAdministration object to still act upon these site collections.

To see the entire function definitions view the full script which is available for download in the Script Library.

 

Comments

There are no comments yet for this post.
Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Comments *


Name (required) *


Attachments
 
 
   
Real Time Web Analytics