TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
PowerShell Script to Set Quota Template to a SharePoint Site Collection
Karthik Muthu Karuppan
Jan 28
2015
Code
6.4
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
SetQuotaTemplate.zip
$LogTime = Get-Date -Format yyyy-MM-dd_hh-mm
$LogFile =
".\SetQuotaTemplatePatch-$LogTime.rtf"
# Add SharePoint PowerShell Snapin
if
( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $
null
) {
Add-PSSnapin Microsoft.SharePoint.Powershell
}
$scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent
Set-Location $scriptBase
#Deleting any .rtf files in the scriptbase location
$FindRTFFile = Get-ChildItem $scriptBase\*.* -include *.rtf
if
($FindRTFFile)
{
foreach($file
in
$FindRTFFile)
{
remove-item $file
}
}
start-transcript $logfile
[string]$url = Read-Host
"Enter the site collection url: [e.g. http://server_name]"
[string]$template = Read-Host
"Enter the quota template name that has to be used: [e.g. MyTemplate]"
try
{
Write-host
"Configuring site collection to use specified quota template ..."
$quotaTemplate = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.QuotaTemplates |
Where-Object {$_.Name -eq $template}
Set-SPSite -Identity $url -QuotaTemplate $quotaTemplate
}
catch
[Exception] {
Write-Error $Error[0]
$err = $_.Exception
while
( $err.InnerException ) {
$err = $err.InnerException
Write-Output $err.Message
}
}
SharePoint
SharePoint Site Collection