Web Templates – SharePoint 2013 – Presentation

February 6, 2015

My Presentation, sometime weeks back
Agenda:
• Introduction to Site Templates , Web Templates , Site definitions
• Build in templates with SharePoint 2013

Presentation URL:
 https://1drv.ms/p/s!As0HddhY04bslge-3y0NkEcjcpG9
Online Reference material index :
 https://1drv.ms/x/s!As0HddhY04bsiloZJ7v5eVyDmSs5


SharePoint Farm analysis script

February 4, 2015

Script to analyze the SharePoint farm.

Outputs:
• SiteCollectionStatisticsForWholeSharePointFarm.csv
Will list all the site collections and also important statistics like custom solution( Custom + third party ) installed( see the last column)
• FarmSolutionForWholeSharePointFarm.csv
Will list all the farm solutions and also its important statistics.
• UserSolutionForWholeSharePointFarm.csv
Will list all the user solutions site wise and also its important statistics.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$ErrorActionPreference = "Continue"

$OutputFarmSolution="C:\FarmSolutionForWholeSharePointFarm.csv";
"SolutionId , Name ,DisplayName , SolutionFile ,Status , Deployed , JobExists " | Out-File -Encoding Default -FilePath $OutputFarmSolution;
  Get-SPSolution   | select -Property SolutionId , Name ,DisplayName , SolutionFile ,Status , Deployed , JobExists  |  Out-File -Encoding Default -Append -FilePath $OutputFarmSolution;

$OutputUerSolution="C:\UserSolutionForWholeSharePointFarm.csv";
"SolutionId , Name ,Status " | Out-File -Encoding Default -FilePath $OutputUerSolution;

foreach ($websvc in $websvcs) {           
    foreach ($webapp in $websvc.WebApplications) { 
      # Remove empty or admin web application
     if ( $webapp.Name -ne '' )    
        {
         # for all sites in a web application
         foreach ($Site in $webapp.Sites) { 
         " >>  " + $Site.Url | Out-File -Encoding Default -Append -FilePath $OutputUerSolution ;  
          Get-SPUserSolution -site $Site.Url  | select  -Property SolutionId , Name ,Status  | Out-File -Encoding Default -Append -FilePath $OutputUerSolution;
         }
         }
         }
         }

#
# This script will fetch all the statistics related to all site in farm
#
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local 
$solutionIdList = Get-SPSolution   | select -Property SolutionId
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]} 
$webapps = @() 
$Output="C:\SiteCollectionStatisticsForWholeSharePointFarm.csv";
"Web Application Name"+","+"Content Database Name"+","+"Site URL"+","+"Owner Login"+","+"Owner Email"+","+"Root Site Last Modified"+","+"Quota Limit (MB)"+","+"Total Storage Used (MB)"+","+"Site Quota Percentage Used"+ ","+"Feature data" | Out-File -Encoding Default -FilePath $Output;

foreach ($websvc in $websvcs) {           
    foreach ($webapp in $websvc.WebApplications) {  
      # Remove empty or admin web application
     if ( $webapp.Name -ne '' )    
        {
         
         # for all sites in a web application
         foreach ($Site in $webapp.Sites) {  
          # log feature related data in this varaible  
          $featureData='';    
          # get all site level features     
          $Current_features = Get-SPFeature -Site $Site.Url
          # loop all web of site and log all web features
          foreach( $web in $Site.AllWebs)
          {
            $Current_features += Get-SPFeature -Web $web.Url
          }    
          #filter duplicate features 
          $Current_features = $Current_features | select -uniq 
          #for all features of site ( site + web level)
         foreach ($feature in $Current_features){         
         $grp= Get-SPFeature -Identity $feature | Group-Object SolutionId;
         $feat= Get-SPFeature -Identity $feature ;        
         if ($grp.Name -ne  "00000000-0000-0000-0000-000000000000")
         {
          $sol = Get-SPSolution -Identity $grp.Name
          # if solution is not a farm solution, but a user solution
          if (! $sol)
          {   
          $sol = Get-SPUserSolution -Site $Site.Url -Identity $grp.Name 
          }
          # if a valid solution
          if ( $sol){   
           $cc = [System.Globalization.CultureInfo]::CurrentCulture;   
           $featuresDefn = GetFeatureDefinition   $feature;
           $featureData += '             '+ $sol.Name ;#+ '(Feature Name:'+ $featuresDefn.GetTitle($cc)+ ') '
          }
         }       
         }

         if ($Site.Quota.Storagemaximumlevel -gt 0) {[int]$MaxStorage=$Site.Quota.StorageMaximumLevel /1MB} else {$MaxStorage="0"}; 
         if ($Site.Usage.Storage -gt 0) {[int]$StorageUsed=$Site.Usage.Storage /1MB};
         if ($Storageused-gt 0 -and $Maxstorage-gt 0){[int]$SiteQuotaUsed=$Storageused/$Maxstorage* 100} else {$SiteQuotaUsed="0"}; 
   
    $Web=$Site.Rootweb;    
    if ($Site.Owner)
    {
    $ownerName = $Site.Owner.Name;
    $ownerEmail = $Site.Owner.Email;
    }
    else
    {
    $ownerName = "N/A";
    $ownerEmail = "N/A";
    }

    if ($Web.LastItemModifiedDate )
    {
    $modifiedDate = $Web.LastItemModifiedDate.ToShortDateString() ;
    }
    else
    {
    $modifiedDate ="N/A";
    }

   $webapp.Name +"," +$Site.contentdatabase.Name +"," + $Site.Url + ","+$ownerName.Replace(',','')+","+$ownerEmail+","+$modifiedDate+"," +$MaxStorage+","+$StorageUsed + "," + $SiteQuotaUsed + "," + $featureData | Out-File -Encoding Default -Append -FilePath $Output;
   $Site.Dispose()
         }

       }  
        
    }  
}