Powershell Script to Get the List of Available SharePoint Quota Templates

  1. $LogTime = Get-Date -Format yyyy-MM-dd_hh-mm  
  2. $LogFile = ".\AvailableQuotaTemplatesPatch-$LogTime.rtf"  
  3.  
  4. # Add SharePoint PowerShell Snapin  
  5.   
  6.   
  7. if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {  
  8.     Add-PSSnapin Microsoft.SharePoint.Powershell  
  9. }  
  10.   
  11. $scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent  
  12. Set-Location $scriptBase  
  13.  
  14.  
  15. #Deleting any .rtf files in the scriptbase location  
  16. $FindRTFFile = Get-ChildItem $scriptBase\*.* -include *.rtf  
  17. if($FindRTFFile)  
  18. {  
  19.   foreach($file in $FindRTFFile)  
  20.   {  
  21.    remove-item $file  
  22.   }  
  23. }  
  24.   
  25.   
  26. start-transcript $logfile  
  27.   
  28. try {  
  29.   
  30.    Write-host "Get quota templates in Quota Template Collection ..."  
  31.    $quotaTemplates = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.QuotaTemplates  
  32.    Write-Output $quotaTemplates  
  33. }  
  34. catch [Exception] {  
  35.    Write-Error $Error[0]  
  36.    $err = $_.Exception  
  37.    while ( $err.InnerException ) {  
  38.       $err = $err.InnerException  
  39.       Write-Output $err.Message  
  40.    }  
  41. }