When considering an upgrade to a SharePoint environment, one of the first question people ask is "What do I have to do?" 

Upgrading to a newer version can be tedious, especially if your current environment is heavily used and contains a variety of site templates or lots of data. I have done several migration projects in the past year and found there are three questions you should always ask before you start.

  1. What is the current Site Hierarchy? (Having a visual map of your current site hierarchy will allow you to see what all you have to migrate.) 
  2. What site templates are being used?  (Each site that is created has to be created using site template. Whether it is an out-box site template or custom one, the site templates are key component for considerations during a migration process because some site templates may or may not be support in newer versions.)
  3. How much content data is current being used? (This is my personal favorite, because the response I get is always different depending on who you ask. If you find that some areas in your environments that are consuming large amounts of data storage this might be a good time to do some clean up or archiving of data so that you don’t bring unwanted or unnecessary data over during the migration process.) 

 

 PowerShell Solutions

Here are two PowerShell scripts that you can perform to output some general information about your current environment. The first script will generate a report that lists all the site(s) and the site template that was used when the site was created. The second script generates a report on how much space is being used.

 Site Hierarchy and Site Templates code snippet

#add header to file 

"Site Collection URL,Web URL,Web Title,Web Template" | out-file "c:\SP_Webs.csv" -append 

#Iterate  through the web applications

foreach ($site in get-spsite) { 

    write-host $site.url 

    

    #Iterate through all the sites within the current web application 

     foreach ($web in $site.AllWebs){ 

        $siteUrl = $site.url 

        $webUrl = $web.url 

        $webTitle = $web.Title 

        $webTemp = $web.WebTemplate 

         

        #output the info to a file 

        "$siteUrl,$weburl,$webTitle,$webTemp" | out-file "c:\SP_Webs.csv" -append 

    } 

} 



Current data storage size code snippet 

  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 

} 

 


Save the above script to filename “GetWebSizes.ps1” then execute the following PowerShell command: 

 

GetWebSizes -StartWeb <StartURL>




For more information on C5 Insight or this blog entry, please  Contact Us.