none
Need powershell script to get website storage details RRS feed

  • Question

  • Hi all, 

    can any one provide the powershell script for getting the storage details of all the web sites in a site collection ?

    Thanks & Regards

    Anil

    Thursday, January 10, 2013 9:32 AM

Answers

  • Hi Anil,

    Yes, You can Get the size of a sub-site with PowerShell. Here is the script:

    # Get Size of all Subsites in a Site Collection.

    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $SiteURL = "http://sharepoint.crescent.com" $Site = new-object Microsoft.SharePoint.SPSite($SiteURL) foreach($Web in $Site.AllWebs) { $WebSize = GetFolderSize($Web.RootFolder) #Call function to calculate Folder Size #Get Recycle Bin Size foreach($RecycleBinItem in $Web.RecycleBin) { $WebSize += $RecycleBinItem.Size } $formatSize = [Math]::Round($websize/1MB, 2) Write-Host $web.Url ":`t" $formatSize } # Function to calculate folder size Function GetFolderSize($folder) { $FolderSize = 0 foreach ($File in $Folder.Files) { #Get File Size $FolderSize += $file.TotalLength; #Get the Versions Size foreach ($fileVersion in $file.Versions) { $FolderSize += $fileVersion.Size } } foreach ($subfolder in $folder.SubFolders) { $FolderSize += GetFolderSize $SubFolder } return $FolderSize }

    Regards,

    Sal

    ---------------------------

    My SharePoint Blog: http://www.SharePointDiary.com

    Thursday, January 10, 2013 1:17 PM

All replies

  • Hello Anil,

    Just check this out 

    http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=270


    Warm Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/ | Posting is provided "AS IS" with no warranties, and confers no rights Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

    Thursday, January 10, 2013 9:57 AM
    Moderator
  • Hi Pratik,

    AS I have mentioned clearly in my question, I want the storage details of all the "webs", not of the "site collections" , but the link that u have given is all about site collections' storage.

    Anyway thanks for ur quick response.

    Best Regards

    Anil

    Thursday, January 10, 2013 12:05 PM
  • Hi Anil,

    Yes, You can Get the size of a sub-site with PowerShell. Here is the script:

    # Get Size of all Subsites in a Site Collection.

    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $SiteURL = "http://sharepoint.crescent.com" $Site = new-object Microsoft.SharePoint.SPSite($SiteURL) foreach($Web in $Site.AllWebs) { $WebSize = GetFolderSize($Web.RootFolder) #Call function to calculate Folder Size #Get Recycle Bin Size foreach($RecycleBinItem in $Web.RecycleBin) { $WebSize += $RecycleBinItem.Size } $formatSize = [Math]::Round($websize/1MB, 2) Write-Host $web.Url ":`t" $formatSize } # Function to calculate folder size Function GetFolderSize($folder) { $FolderSize = 0 foreach ($File in $Folder.Files) { #Get File Size $FolderSize += $file.TotalLength; #Get the Versions Size foreach ($fileVersion in $file.Versions) { $FolderSize += $fileVersion.Size } } foreach ($subfolder in $folder.SubFolders) { $FolderSize += GetFolderSize $SubFolder } return $FolderSize }

    Regards,

    Sal

    ---------------------------

    My SharePoint Blog: http://www.SharePointDiary.com

    Thursday, January 10, 2013 1:17 PM
  • Hey Salaudeen,

    Thank you very much for your script.

    Best Regards

    Anil

    Monday, January 14, 2013 5:00 AM
  • Hi Salaudeen,

    Nice script, but at least for MOSS I had to move the function code above "foreach" enuming each web in the site collection.

    Best,

    Jeff

    Friday, March 31, 2017 11:39 PM