Script for calculating SharePoint SPWeb size
SharePoint portal in active company grows like an anthill. Setting limits of SharePoint sites can protect from problems with disk spaces, but it makes more users requests that not all the administrators like. So I think a good tone not to set limits on SharePoint sites.
But in this case we need monitoring of sites to see how much space they take.
For this I posted a useful powershell script to see disc usage by SharePoint sites. Here it is.
<# Script for calculating SharePoint SPWeb size #> if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Write-Host "Pluging Sharepoint modules" Add-PSSnapin Microsoft.SharePoint.PowerShell } function GetWebSizes ($StartWeb) { $web = Get-SPWeb $StartWeb [long]$total = 0 $total += GetWebSize -Web $web $total += GetSubWebSizes -Web $web $totalInMb = ($total/1024)/1024 $totalInMb = "{0:N2}" -f $totalInMb $totalInGb = (($total/1024)/1024)/1024 $totalInGb = "{0:N2}" -f $totalInGb write-host "Total size of all sites below" $StartWeb "is" $total "Bytes," write-host "which is" $totalInMb "MB or" $totalInGb "GB" $web.Dispose() } function GetWebSize ($Web) { [long]$subtotal = 0 foreach ($folder in $Web.Folders) { $subtotal += GetFolderSize -Folder $folder } write-host "Site" $Web.Title "is" $subtotal "KB" return $subtotal } function GetSubWebSizes ($Web) { [long]$subtotal = 0 foreach ($subweb in $Web.GetSubwebsForCurrentUser()) { [long]$webtotal = 0 foreach ($folder in $subweb.Folders) { $webtotal += GetFolderSize -Folder $folder } write-host "Site" $subweb.Title "is" $webtotal "Bytes" $subtotal += $webtotal $subtotal += GetSubWebSizes -Web $subweb } return $subtotal } function GetFolderSize ($Folder) { [long]$folderSize = 0 foreach ($file in $Folder.Files) { $folderSize += $file.Length; } foreach ($fd in $Folder.SubFolders) { $folderSize += GetFolderSize -Folder $fd } return $folderSize } GetWebSizes -StartWeb http://yourspportal/site/
You didn’t really write it, did you?
Comment by WTF — October 29, 2015 @ 9:27 am
Hello I am so happy I found your website, I really found you by
error, while I was browsing on Digg for something else,
Regardless I am here now and would just like to say thanks a lot for
a tremendous post and a all round thrilling blog (I also
love the theme/design), I don’t have time to go through it all at the minute but I
have book-marked it and also added in your RSS feeds, so when I have time I will be back
to read more, Please do keep up the excellent work.
Comment by residencia de estudiantes en madrid — June 17, 2017 @ 11:03 pm