Friday, May 11, 2018

Ffixing the STS service is unavailable issue

Monday, January 11, 2016

Sharepoint web.config backup using powershell

Here is the PowerShell that i use in my SharePoint farm to backup PowerShell on WFE. I have added the script as scheduled task on windows WFE server in the farm.

The PowerShell goes as below.

#Developed by Hemant Basavapattan for web.config Backup

Add-PSSnapin -Name Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue
$webappName = “YourWebappName”
$backupDir = “D:\Backups\Web_Config_Backup”
Write-Host "Backing up $webappName web.config file…" -foreground Gray –nonewline
## Get the web application – by display name
$w = Get-SPWebApplication | where { $_.DisplayName -eq "$webappName"}
## Get the default (first) zone for the web app…
## You may wish to iterate through all the available zones
for($i=0; $i -lt $w.AlternateUrls.Count; $i++)
 $zone = $w.AlternateUrls[$i].UrlZone
 ## Get the collection of IIS settings for the zone
 $iisSettings = $w.IisSettings[$zone]
 ## Get the path from the settings
 $path = $iisSettings.Path.ToString() + "\web.config"
 ## copy the web.config file from the path
 $a = (Get-Date).ToString('MM-dd-yyyy')
 New-Item -ItemType Directory -Force -Path $backupDir\$a\$url
 copy-item $path -destination $backupDir\$a\$url
Write-Host "done" -foreground Green

I have modified Brian's post to suit my requirements of multi-authentication extended WebApp's

Thursday, December 3, 2015

GetContentDB script for mounting/unmounting and upgrade during SharePoint patching

#Purpose:  Scans all attached Databases and can create mount/unmount scripts to add or drop all sharepoit content dbs. This script does not touch config or service application application database.

#The script is provided as is and holds no warranty.

#Usage:  create script to mount all databases

$ver = $host | select version
if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"}
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" }
$stuff = '$ver = $host | select version; if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"}; if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" }; $Log = ($EnvPrefix + "_Log_"  + (get-date -format "yyyymmdd_HHMMss") + ".PS1")'

$EnvPrefix = read-host "Enter Environment:  DEV | IT | UAT | PROD "

$fileAttach = ($EnvPrefix + "_AttachDB.ps1")
$fileDetach = ($EnvPrefix + "_DetachDB.ps1")

# Load Microsoft.SharePoint Assembly
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration")

"# Detach all Content DB's "  | Out-File $fileDetach
"# Attach all Content DB's "  | Out-File $fileAttach
$stuff | Out-File $fileDetach
$stuff | Out-File $fileAttach 
foreach($webapp in get-spwebapplication)
 'get-date -format "yyyy-mm-dd HH:mm:ss"'| Out-File $fileDetach -Append
 'get-date -format "yyyy-mm-dd HH:mm:ss"'| Out-File $fileAttach -Append
 'write "Processing Web Application: ' + $webapp.Name + '"' | Out-File $fileDetach -Append
 'write "Processing Web Application: ' + $webapp.Name + '"' | Out-File $fileAttach -Append
    " "  | Out-File $fileDetach -Append
    " "  | Out-File $fileAttach -Append
 $get_Server = [Microsoft.SharePoint.Administration.SPContentDatabase].getmethod("get_Server")
 $get_Database = [Microsoft.SharePoint.Administration.SPContentDatabase].getmethod("get_Name")

 foreach($cd in $webapp.ContentDatabases)
  $url = $webapp.GetResponseUri("Default").OriginalString
  $dbName = $get_Database.Invoke($cd, "instance,public", $null, $null, $null)
  $server = $get_Server.Invoke($cd, "instance,public", $null, $null, $null)
  'get-date -format "yyyy-mm-dd HH:mm:ss"'| Out-File $fileDetach -Append
  'get-date -format "yyyy-mm-dd HH:mm:ss"'| Out-File $fileAttach -Append
  "Mount-SPContentDatabase "+ $dbname + " -DatabaseServer "+ $server + " -WebApplication " + $url | Out-File $fileAttach -Append
  "dismount-SPContentDatabase "+ $dbname | Out-File $fileDetach -Append
  '$date = get-date -format "yyyy-mm-dd HH:mm:ss"; $date + ";Detach;" + ' + '"' + $dbName +'"' + ' | Out-File $log -Append ' | Out-File $fileDetach -Append
  '$date = get-date -format "yyyy-mm-dd HH:mm:ss"; $date + ";Attach;" + ' + '"' + $dbName +'"' + ' | Out-File $log -Append ' | Out-File $fileAttach -Append

Thursday, October 15, 2015

Sharepoint Verbose logging using Powershell

We always wonder how to change the logging mode to Verbose in Sharepoint for logs very quickly and get back to normal whithout getting banged by other team members while debugging any issue in SharePoint farm.

Here are the Steps

1) Open SharePoint Management Shell As admin

2) Run the below command to create a new file.

3) Record the start Time

4)Change the mode to Verbose

      Set-SPLogLevel -TraceSeverity Verbose -EventSeverity Verbose -verbose
     stsadm -o setlogginglevel -tracelevel verbose
5) Recreate the issue

6) Rember to Clear the Log level to default else you will run into Space issue

7) Record the End Time

8) Merge the logs

      Merge-SPLogFile -Path "d:\Logs\PP.log" -Overwrite -StartTime "10/15/2015 15:51" -EndTime "010/15/2015 15:54"

The above steps are also helpful if your central admin is giving some issues and you are not able to change the log level but i like Powershell  and its damm Quick.

Wednesday, August 26, 2015

SharePoint 2016

SharePoint 2016 – Quick Facts

  • Release milestones: Public beta – Q4 2015, public download – Q2 2016 and a release candidate (RC) in between.
  • The design, development and maintenance for SharePoint 2016 going tinherit from cloud DNA.
  • Focusing on content management, team collaboration, user experience across devices and how the cloud can be blended intexisting on-premises scenario.
  • New and improved capabilities will be delivered focusing on
    • Improved User Experience
      • Improved mobile experience
      • Personalized insights
      • People-focused File storage and collaboration
      • Power of Office graph and Delve (via hybrid)
  • Cloud-inspired infrastructure
    • Improved performance and reliability
    • Hybrid cloud with global reach
    • Support and monitoring tools
    • Simplified user experience and integration with products like next version of Win Server, SQL Server, Exchange Server 2016.
  • Compliance and Reporting
    • New DLP
    • Enable data encryption
    • Improved Analytic and reporting
    • Microsoft taken SharePoint online, modified tsuite on-premises. Components which were not available are back ported.

SharePoint 2016 - New & Improved Features

New information available for SharePoint 2016 can be classified in 4 categories:

1. Management of platform

Hardware Requirements

Installation ScenarioMemory / RAMProcessorHard Disk
Single Server*16-24 GB64-bit, 4 cores80 GB
Farm Server12-16 GB64-bit, 4 cores80 GB
Database ServerRefer system requirement for 64-bit version of SQL Server 2014 Service Pack 1 or SQL vNext
*There is nbuilt in SQL Server. You need tinstall a separate SQL Express/Developer or any other edition even for development server.

Software Requirements

  • Any one of Windows Server 2012 R2 | Windows Server 10
  • Windows Management Framework 3.0
  • Application Server Role
  • Web Server (IIS) Role
  • Microsoft .NET Framework 4.5.2 (in on Windows Server 10, then Microsoft .NET Framework 4.5.6)
  • Update for the .NET Framework 4 (KB2898850)
  • Microsoft SQL Server 2012 Native Client
  • Microsoft Identity Extensions
  • Microsoft Sync Framework Runtime v1.0 SP1 (x64)
  • Windows Server AppFabric v1.1 (MS is planning tend AppFabric, but it will be supported for SP 2013 and 2016).
  • Windows Identity Foundation v1.1
  • Microsoft Information Protection and Control Client
  • Microsoft WCF Data Services.

Upgrade and Migration

  • Upgrade path is from 2013 t2016
    • Upgrade 14.5 mode site to 15 mode and then upgrade
    • Allow the same database attach upgrade process
  • Migrate Content to 2016 (using migration APIs or partner tools)

Auth N-Z

  • Windows Identity over SAML claims
  • Trying tnormalize on oAuth/OpenID standards

SMTP Connection

  • Allow using non-default ports
  • Allowing tuse STARTTLS connection encryption.

2. Reliability, Performance and scalability

  • Moving from SharePoint 2013 based job enable / disable tpredefined set of logic executing on a machine (Termed as MinRole Topology)
  • New Server Roles in SharePoint 2016
    • Special Load – custom service applications, services, third party components which are outside of MinRole Topology
    • Web Front End – services end user requests. Servers are optimized for low latency
    • Search – service application provisioning, indexing service and other search components.
    • Application – services backend jobs or requests triggered by backend jobs. Servers are optmized for high throughput
    • Distributed Cache – servers distributed cache for the farm.
    • Single Server Farm – for development purpose, configure (excluding SQL Server) all services on one server.
  • New Service categories in SharePoint 2016
    • User Services
    • Robot Services
    • Caching Services
  • Server Role and Health Analyzer
  • Patching Updates
  • Improvement in boundaries and limits
    • Content DB size upto TB’s (not yet identified the limit)
    • 100K sites per site collection
    • List view threshold > 5000 items
    • Upload file size upto 10 GB and removed character restrictions
    • Search scaling upto 500 M items.
  • Better File Performance
    • Use BITS (Background Intelligent Transfer Service) tbetter file performance
  • Fast Site Creation
    • Create faster site collections at database level using the standard site template saved as site.
    • Remove feature activation overhead
  • User Profile Service
    • Bi-directional sync using external FIM service. Nbuilt in FIM anymore.
  • Project Server
    • Still require separate Project Server Licensing, but SharePoint and Project Server content database is merged.
  • Durable Links
    • New sharing URLs are resources Id based, thus renaming file, moving file will not break the link already shared.

3. Analytics (Insights and Data)

  • Real time data analysis on various parameters
    • Usage
      • daily active users
      • Weekly active users
      • Usage by browser
      • Usage by agent
      • Usage by OS
    • Storage
      • Storage by site template
      • Daily storage
      • File type
      • Storage breakout
    • Health Reports
    • Network
    • Portals

4. Cloud Experience

  • Compliance Center
    • This showcase the feasibility of bringing same compliance system ton-premises which works well in O365 with Azure RMS.
    • Discover and preserve with hybrid eDiscovery.
  • Cloud Search Service Application
    • This unifies the on-premises and cloud data search from one search center.
    • This alsadd value tOffice Graph / Delve textend the presence on on-premises.
    • This can alsleave search running in cloud only while indexing from on-premises and online.
  • Extranet
    • Making easier tmaintain and publish sites tInternet.
    • Using O365 Identity federation services.
  • Team Sites
    • Separate the data in either on-premises or in cloud
    • Follow sites, documents or people in on-premises and master the information in cloud.
    • Allowing ODF files creation.
  • ScenariPicker
    • Hybrid deployment automation
    • Select the Hybrid configuration required and use automated and wizard driven information tsetup Hybdrid (forget the lengthy procedures and PowerShell scripts trun)
Note: the information in this blog post is based on the information presented and available on public forums. The actual product SharePoint 2016 can have difference from what is available. Please dtake time tcheck the new features when the product is released.

Source and Courtsey:Microsoft

SharePoint 2016 New Admin features

Services on Server

Services in Farm
Role conversion in Central Admin

Outgoing Email

Role Installation Option during Installation

Monday, August 24, 2015

SharePoint 2013 search 2 server Powershell

The below scripts helps all the search components on both the server in the sharepoint farm. It also provides option to specify the location of Primary and Secondary Index

if ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null )
Add-PsSnapin "Microsoft.SharePoint.PowerShell"

#enter the Server name

#Enter the app pool account and database details below
$SearchAppPoolAccountName = ""

#Set the primary and replica index location; ensure these drives and folders exist on application servers

$SearchServiceName="Search Service Application"
$SearchServiceProxyName="Search Service Application Proxy"

#Create a Search Service Application Pool
$spAppPool=New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose

#Start Search Service Instance on all Application Servers
Start-SPEnterpriseSearchServiceInstance $App1 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchServiceInstance $App2 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $App1 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $App2 -ErrorAction SilentlyContinue

#Create Search Service Application
$ServiceApplication=New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseName $DatabaseName -DatabaseServer $DatabaseServer

#Create Search Service Proxy
New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication

$clone = $ServiceApplication.ActiveTopology.Clone()
$App1SSI = Get-SPEnterpriseSearchServiceInstance -Identity $app1
$App2SSI = Get-SPEnterpriseSearchServiceInstance -Identity $app2

#We need two Admin processing components for HA
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $App1SSI
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $App2SSI

#We need two content processing components for HA
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $App1SSI
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $App2SSI

#We need two analytics processing components for HA
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $App1SSI
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $App2SSI

#We need two crawl components for HA
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $App1SSI
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $App2SSI

#We need two query processing components for HA
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $App1SSI
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $App2SSI

#We need two index partitions and replicas for each partition. Follow the sequence.
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App1SSI -RootDirectory $PrimaryIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App2SSI -RootDirectory $ReplicaIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App2SSI -RootDirectory $PrimaryIndexLocation -IndexPartition 1
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App1SSI -RootDirectory $ReplicaIndexLocation -IndexPartition 1


The Other three database names are created by default. This is the most robust and highly available search I have used in case of 2 App servers.

Source Powershell Magzine and MSDN

Friday, July 17, 2015

Delete Subsites using CSV SharePoint 2010

This script has some issue related to logging of failed site but site delete works fine.

# Completely deletes the specified Web (including all subsites)
function RemoveSPWebRecursively(
    [Microsoft.SharePoint.SPWeb] $web)
    Write-Debug "Removing site ($($web.Url))..."
    $subwebs = $web.GetSubwebsForCurrentUser()
    foreach($subweb in $subwebs)
    $DebugPreference = "SilentlyContinue"
    Remove-SPWeb $web -Confirm:$false
    $DebugPreference = "Continue"
     $text | Add-Content 'failedsites.txt'

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
Start-Transcript -path ".\SiteDelete.log"
$text | Set-Content 'failedsites.txt'
$csv = Import-Csv ".\delete.csv"
foreach ($line in $csv)
      $web = Get-SPWeb $line.URL
      If ($web -ne $null)
          RemoveSPWebRecursively $web
     $text | Add-Content 'failedsites.txt'

Wednesday, June 3, 2015

Template Id for Sharepoint 2010

Base Type
Generic List
Document Library
Discussion List
Issue List

The following table lists all available list templates with their template type id and their corresponding feature id:

Type of list
 Generic List



 Document Library






 Links List



 Announcements List



 Contacts List



 Events List



 Tasks List



 Discussion List



 Picture Library



 Data Sources



 Site template gallery


 User Information List


 Web Part gallery


 List Template gallery


 XML Form Library



 Master Pages gallery


 No-Code Workflows



 Custom Workflow Process



 Wiki Page Library



 Grid List



 Data Connection Library



 Workflow History



 Gantt Task List



 Meeting Series List


 Meeting Agenda List


 Meeting Attendees List


 Meeting Decision List


 Meeting Objectives List


Meeting Things to Bring List


 Meeting Workspace Pages List


 Blog Posts List


 Blog Comments List


 Blog Categories List


 Status Indicator (KPI) List



 Report Library



 Publishing Pages Library


 Issue Tracking List



 Administrator Tasks List


 Translation Management Library



 Translation List



Slide Library