Get SharePoint Site Quota Templates using PowerShell

A week or two ago I posted a function that allows you to create new SharePoint Site Collection Quota Templates using PowerShell. In that post I mentioned that two more functions (Get, Remove) would be coming soon.

Today I am sharing the function which allows you to get SharePoint Quota Templates. Again, this code is almost verbatim taken from the book by Gary and Shannon, but I have added comment-based-help and put it into an advanced function with CmdletBinding attributes.

The code is pretty simple, and again if you want a detailed walk through – I strongly encourage you to check out Gary and Shannon’s book!

Without further ado, here is the function which I have called Get-SPQuotaTemplate. I’m also finishing up the third function, Remove-SPQuotaTemplate – look for that post very soon!

Simply dot-source the function and then run it like a standard Windows PowerShell Cmdlet.

function Get-SPQuotaTemplate {
 This advanced function retrieves a SharePoint Site Quota Template.
 This function uses .NET code to retrieve the Quota Templates collection
 using a Microsoft.SharePoint.Administration.SPWebService object.
 C:\PS>Get-SPQuotaTemplate -Name "Custom"

 This example retrieves a SharePoint Quota Template called Custom in the
 current farm.

 This example retrieves all SharePoint Quota Templates in the current farm.
 Name: Get-SPQuotaTemplate
 Author: Ryan Dennis
 Last Edit: 5/10/2012
 Keywords: Quota Template, Quotas and Locks
#Requires -Version 2.0
$Templates = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.QuotaTemplates
 if ($Name)
 $Templates | Where-Object {$_.Name -eq $Name}


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s