Hi Guys,
I had a requirement from my client to provide them the report contains all the sub sites memory consumption in a site collection.
In Moss 2007, we don't have any OOTB to find the memory consumption for each sub site.
After tried in Google, I found the below power shell script that could be useful .
After you run the above scripts together, you can call it with the following PowerShell command: GetWebSizes -StartWeb
The start url could be any subsite url, that may not be a top level site.
Note: The script is written om SharePoint 2010 version, by changing the Get-SPWeb cmdlet to 2007 version ( like $site=new object Microsoft.Sharepoint.SPSite('ur')) , it could work well.
I had a requirement from my client to provide them the report contains all the sub sites memory consumption in a site collection.
In Moss 2007, we don't have any OOTB to find the memory consumption for each sub site.
After tried in Google, I found the below power shell script that could be useful .
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 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
}
After you run the above scripts together, you can call it with the following PowerShell command: GetWebSizes -StartWeb
The start url could be any subsite url, that may not be a top level site.
Note: The script is written om SharePoint 2010 version, by changing the Get-SPWeb cmdlet to 2007 version ( like $site=new object Microsoft.Sharepoint.SPSite('ur')) , it could work well.
No comments:
Post a Comment