How to get document libraries size in your SharePoint Server 2007/2010/2013


How to get every document libraries size in your SharePoint Environment. SP2007/SP2010/SP2013?


 My current client is moving SharePoint On-Prem to SharePoint Online and they asked me to how much some of the document libraries are taking up size on the server. As most of the document library had more than 5000 Items and were very large libraries.
The logic I came out with was
  • 1.       Find every site collection in the SharePoint Server farm
  • 2.       For every Site collection get all the sites.
  • 3.       For every site get all the document libraries
  • 4.       For each document library get all the items attachments length.
  • 5.       Add it up per library and that should give total size on the server as shown below.


Following is the screenshot of output generated.





Following script generates the above output:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null

function Get-Inventory(){
 $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
 $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
 $webapps = @()

 foreach ($websvc in $websvcs)
 {
     write-host "Web Applications"
     write-host ""
     foreach ($webapp in $websvc.WebApplications)
     {
         write-host "Webapp Name -->"$webapp.Name
         write-host ""
         write-host "Site Collections"
         write-host ""
         foreach ($site in $webapp.Sites)
          {
            write-host "Site URL --> -->" $site.URL
            write-host ""
            write-host "Websites"
            write-host ""
             foreach ($web in $site.AllWebs)
             {
                    write-host ""
                    write-host ""
                    foreach ($list in $web.Lists) {
                        if ($list.BaseType -eq "DocumentLibrary") {
                          if(CheckSystemLibrary($list.Title))
                          {
                                $listSize = 0
                                foreach ($item in $list.items)
                                {
                                    $listSize += ($item.file).length
                                }                               
                                #"Web: "+$web.Title+", Library Name: "+$list.Title+",  "+[Math]::Round(($listSize/1KB),2)+" KB " 
                                $size = [Math]::Round(($listSize/1KB),2) 
                                $line = @{
                                            "Web" = $web.Title
                                            "URL" = $web.URL
                                            "Library"   =  $list.Title
                                            "Size-KB" =  $size
                                         }
                                New-Object PSObject -Property $line | select "Web","URL","Library","Size-KB"                                        
                               
                          } #end if checksystemlibrary      
                        } #foreach list.
                     }                     
             } #web
          } # site
      } # webapp
     } #websvc
   } #function.
  
   function CheckSystemLibrary($sysLib)
   {
       
        $arrLib = "Site Collection Documents", "Site Collection Images", "Site Images", "Site Pages", "Site Template Gallery","Site Templates", "Style Library", "Web Part Gallery",
                "Pages","Site Views","SitePages"
        $found = $arrLib -contains $sysLib
        return -Not $found
   }
  
                cls
                Get-Inventory | Export-Csv -NoTypeInformation -Path C:\Scripts\Output.csv       





How can you move SharePoint 2010 designer workflow from one server to another server?



By following the hack, you can move the SharePoint designer workflow from the Development server to production server.
Step
1.       In SP Designer, Open workflow and click Export to Visio. Save the file to the local folder yourWF.VWI extension.
2.       Rename the yourWF.vwi to yourWF.vwi.zip
3.       Open the .zip file and find  workflow.xoml.wfconfig.xml and delete it.
4.       Open you destination in designer and Import workflow.
5.       When you Import it will ask for list/library to configure it to your destination list/library.


Step 1: Screenshot.


Step 2: Rename the file


Step 3 & Step 4 As shown below





Step 5: Rename the file back.

Step 6: Create a new WF on destination server and import from Vision and select the file;

Step 7: It should ask to associate to the list/library viola ; it is done!!! Now you have workflow on the destination server.

SharePoint 2013 Visio Web Part access Error


SharePoint 2013 Visio Web Access Web part Error.  The Server Failed to process the request.






You can resolve the above problem by giving service account (sp_services) sysadm role in SQL Database.


How to find the service account which needs db_owner in SQL Db.??

Run the following commands in powershell. to find out what is the service ID

Get-SPServiceApplicationPool | Select Id, Name


Get-SPServiceApplicationPool -Identity "SharePoint Hosted Services"


I got the service ID which is used for SharePoint Hosted Services. And that is svc_spp_service on the My server.


I logged into SQL database and give access to this svc_Spp_service ID sysadmin access in MS SQL server.  And my problem was solved.