One of my users asked me to provide a list of all the Site Quota
template limits. This was to be used by him to plan the sites.
I created the below function in Powershell to update the Site
Collection Quota template limits in a SharePoint list. . So here is a
copy of the powershell script and what it does:
1. Reads the Site Collection Quota templates for a web application
2. Updates the list of Quota templates to a SharePoint list
3. Update the status of activity in a status list
Powershell script function
function syncQuotaDetails([string] $webApp,[string] $listName,[string]
$statusListName)
{
try
{
$contentService =
[Microsoft.SharePoint.
$quotaTemplates = $contentService.QuotaTemplates
$spAssignment = Start-SPAssignment
$myList = (Get-SPWeb -Identity $TSAdmin -AssignmentCollection
$spAssignment).Lists[$
$listItems = $myList.Items
$listItemCount = $listItems.Count
for($x = $listItemCount - 1;$x -ge 0;$x--)
{
$listItems[$x].Delete()
}
$countQuotas = 0
foreach($quotaTemplate in $quotaTemplates)
{
if($quotaTemplate.Name -ne "" -and $quotaTemplate.Name -ne "Personal site")
{
$newItem = $myList.Items.Add()
$newItem["QuotaTemplateName"] = $quotaTemplate.name
$countQuotas = $countQuotas + 1
$newItem["QuotaTemplateID"] = $countQuotas;
$newItem["
($quotaTemplate.
$newItem.Update()
}
}
Stop-SPAssignment $spAssignment
$spAssignment = Start-SPAssignment
$myList = (Get-SPWeb -Identity $TSAdmin -AssignmentCollection
$spAssignment).Lists[$
$newItem = $myList.Items.Add()
$newItem["Activity"] = "Synchronise Tiers"
$newItem["Status"] = "Successful";
$newItem["Comment"] = "All Tier Quotas updated"
$newItem.Update()
Stop-SPAssignment $spAssignment
}
catch [Exception]
{
$managedPaths = get-spmanagedpath -webapplication $webApp
$spAssignment = Start-SPAssignment
$myList = (Get-SPWeb -Identity $TSAdmin -AssignmentCollection
$spAssignment).Lists[$
$newItem = $myList.Items.Add()
$newItem["Activity"] = "Synchronise Tiers"
$newItem["Status"] = "Failed";
$newItem["Comment"] = $_.Exception.ToString();
$newItem.Update()
Stop-SPAssignment $spAssignment
}
}
The “QuotaTemplate” list where the above function will store data
should have 2 columns:
1. QuotaTemplateName – Single line of text
2. QuotaTemplateID – Number
3. QuotaTemplateStorage - Number
Similarly the status list where the status of the activity will be
stored should have following column:
1. Activity name – single line of text
2. Status – single line of text
3. Comment – Multiple line of text
Its well written article. All the necessary points are well explained in your article.The information helps me a lot in my working. That is possible because of your user.So thanks to you and that user also.
ReplyDeletee signatures
Simply superb article
ReplyDeletesharepoint 2013 administration certification