param( [string]$url ) 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 } if (-not $url) { Write-Host "Specify site url in url parameter" -foregroundcolor red return } GetWebSizes $url