ĐÀO TẠO DOANH NGHIỆP : SỞ KHOA HỌC CÔNG NGHỆ TỈNH ĐỒNG NAI

ENTERPRISE TRAINING: DONG NAI DEPARTMENT OF SCIENCE AND TECHNOLOGY.

HÌNH ẢNH TẬP HUẤN LỚP SHAREPOINT WORKFLOW VÀ KIẾN TRÚC SHAREPOINT

PHOTOS OF SHAREPOINT WORKFLOW AND ARCHITECTURE CLASS.

HÌNH ẢNH TẬP HUẤN LỚP SHAREPOINT WORKFLOW VÀ KIẾN TRÚC SHAREPOINT

PHOTOS OF SHAREPOINT WORKFLOW AND ARCHITECTURE CLASS.

Showing posts with label Sharepoint 2010 Management Shell. Show all posts
Showing posts with label Sharepoint 2010 Management Shell. Show all posts

Monday, September 26, 2016

Using PowerShell to find site/subsite/list/library size in SharePoint


Size of Site collection and all subsites


#Get Size of all Sub-sites in a Site Collection
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

# Function to calculate folder size
Function CalculateFolderSize($Folder)
{
    [long]$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
        }   
    }
 #Iterate through all subfolders
    foreach ($SubFolder in $Folder.SubFolders)
    {
  #Call the function recursively
        $FolderSize += CalculateFolderSize $SubFolder
    }
    return $FolderSize
}

 
$SiteURL = "http://yoursite"
$Site = new-object Microsoft.SharePoint.SPSite($SiteURL)
  #Array to Hold Result - PSObjects
  $ListItemCollection = @()
 
  foreach($Web in $Site.AllWebs)
  {
    $ExportItem = New-Object PSObject
    #Call function to calculate Folder Size
    [long]$WebSize = CalculateFolderSize($Web.RootFolder)
   
    #Get Recycle Bin Size
    foreach($RecycleBinItem in $Web.RecycleBin)
        {
           $WebSize += $RecycleBinItem.Size
        }
        $Size = [Math]::Round(($WebSize/1024)/1024, 2)
        Write-Host  $web.Url ":`t" $Size "MB"
        $ExportItem | Add-Member -MemberType NoteProperty -name "Web URL" -value $web.Url
        $ExportItem | Add-Member -MemberType NoteProperty -name "Web Size" -value $Size
        $ListItemCollection += $ExportItem
    #Dispose the object
    $web.dispose()
   }
  
   $ListItemCollection | Export-CSV C:\allsubsitesof.csv -NoTypeInformation

Size of Lists and Libraries include version

#Set variables
$siteURL = "http://yoursite"
$site = new-object Microsoft.SharePoint.SPSite($siteURL)

$ListItemCollection = @()
foreach ($web in $site.AllWebs)
{
  foreach ($list in $web.Lists)
   {
   $ExportItem = New-Object PSObject
           $listSize = 0
           foreach ($item in $list.items)
            {
            $listSize += ($item.file).length
            foreach($FileVersion in $item.File.Versions) 
                {
                   $listSize += $FileVersion.Size
                }               
            }
            $Size = [Math]::Round(($listSize/1024)/1024, 2)
            Write-Host  $web.Title ":`t" $list.Title ":`t" $listSize   
            $ExportItem | Add-Member -MemberType NoteProperty -name "WebTitle" -value $web.Title
            $ExportItem | Add-Member -MemberType NoteProperty -name "WebURL" -value $web.URL
            $ExportItem | Add-Member -MemberType NoteProperty -name "WebDescription" -value $web.Description
            $ExportItem | Add-Member -MemberType NoteProperty -name "List_Library_Name" -value $list.Title
            $ExportItem | Add-Member -MemberType NoteProperty -name "Size (MB)" -value $Size
        $ListItemCollection += $ExportItem
    }
   
}
$ListItemCollection | Export-CSV C:\sizeoflistsandlibrary.csv -NoTypeInformation
$Site.Dispose()

Sunday, December 1, 2013

Restore deleted site collection sharepoint 2010 SP1

It have available feature in Sharepoint 2010 SP1=> We have 2 the site collections (Top-level site and site collection)


We delete 2 site collections
Now 2 site collection is deleted
Restore deleted site collection using “SharePoint 2010 Management Shell” => Open “SharePoint 2010 Management Shell” as Administrator
Input get-spdeletedSite

The result: we have 2 site collections was deleted


Input Restore-spdeletedsite –identity “siteid” to restore site collection then enter

Continue input yes then enter


The result as top level site is restored:

Continue restore the second site collection
The result as:

So we finish the guide step. Good luck !!!