question

sns1 avatar image
0 Votes"
sns1 asked ·

Script to figure out site collections which are crossed storage quota

Do we have script to pull the list of site collections which are crossed storage and giving a warning when browsing site.

Here I need list of those storage crossed/warning site collections from targeted set of site collections. Those targeted site collections number between 30 to 40.

Example : if I enter 30 site collections in input file and I should get list of those storage effected site collections in the output Please help.

Thank you.

office-sharepoint-server-administration
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

EmilyDu-MSFT avatar image
0 Votes"
EmilyDu-MSFT answered ·

@sns1
1.Go to Central Administration -> Application Management -> Configure quotas and locks -> Select the site collection -> Set the value of "Send warning e-mail when site storage reaches".
70643-3.png
2.Create an input csv file with site collection URLs.
70653-1.png
3.Run below PowerShell.

 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)   
                 {  
                     Add-PSSnapin "Microsoft.SharePoint.PowerShell"  
                 }  
                                                      
                 $results = @()  
                    
                 $csv = Import-Csv "the local path of csv file, such as C:\sites.csv"
                 $a = $csv.Url
                                                  
                 try   
                 {  
                   foreach ($_ in $a)  
                   {  
                   $Site = Get-SPSite $_
                      
                              $RowDetails = @{  
                                   "Site URL"                            = $site.Url  
                                   "Storage Used"                        = $site.Usage.Storage/1MB  
                                   "Storage Available Warning"           = $site.Quota.StorageWarningLevel/1MB  
                                   "Storage Available Maximum"           = $site.Quota.StorageMaximumLevel/1MB  
                                 }  
                       $results += New-Object PSObject -Property $RowDetails  
                       $site.Dispose()   
                     }   
                 }   
                          
                 catch  
                 {          
                    $e = $_.Exception  
                    $line = $_.InvocationInfo.ScriptLineNumber  
                    $msg = $e.Message   
                      
                    Write-Host -ForegroundColor Red "caught exception: $e at $line"  
                    Write-Host $msg  
                    write-host "Something went wrong"  
                 }   
                      
                 $results | Export-csv -Path "C:\SiteQuotaDetailedInfo.csv" -NoTypeInformation  
                 Write-Host "-------------------- Completed! -----------------------------"

70565-2.png

4.Compare "Storage Used" with "Storage Available Warning" in the output csv file.


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



3.png (35.7 KiB)
1.png (5.2 KiB)
2.png (10.3 KiB)
1.png (5.3 KiB)
· 5 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Emily Du,

Thank you.
Script appears to be working but output file showing 0 KB.

0 Votes 0 ·

@sns1
1.Whether you set the value of "Send warning e-mail when site storage reaches" in the Central Administration?
2.Please provide the screenshot of your input file.


0 Votes 0 ·
sns1 avatar image sns1 EmilyDu-MSFT ·

Hi Emily Du,
1. Yes set. PFA screenshot
2. attached
71077-capture.png71117-capture2.png
71491-mm.jpg


[1]: /answers/storage/temp/71079-capture.jpg

0 Votes 0 ·
capture2.png (578.3 KiB)
capture.jpg (31.6 KiB)
mm.jpg (40.6 KiB)
Show more comments