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
 $url=$w.AlternateUrls[$i].Uri.Authority
 ## 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.
      New-SPLogFile

3) Record the start Time

4)Change the mode to Verbose

      Set-SPLogLevel -TraceSeverity Verbose -EventSeverity Verbose -verbose
     
     or
     
     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
     Clear-SPLogLevel

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
$App1=""
$APP2=""

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

#Set the primary and replica index location; ensure these drives and folders exist on application servers
$PrimaryIndexLocation="D:\Data\Index_Original"
$ReplicaIndexLocation="D:\Data\Index_Replica"

$SearchAppPoolName="SearchAppPool"
$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

$clone.Activate()

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)
    {
        RemoveSPWebRecursively($subweb)
        $subweb.Dispose()
    }
    TRY
    {
    $DebugPreference = "SilentlyContinue"
    Remove-SPWeb $web -Confirm:$false
    $DebugPreference = "Continue"
    }
    Catch
    {
     [system.exception]
     $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)
{
   TRY
    {
      $web = Get-SPWeb $line.URL
      If ($web -ne $null)
       {
          RemoveSPWebRecursively $web
          $web.Dispose()
       }
    }
   Catch
    {
     [system.exception]
     $text | Add-Content 'failedsites.txt'
    }
}
Stop-Transcript

Wednesday, June 3, 2015

Template Id for Sharepoint 2010


Base Type
Description
0
Generic List
1
Document Library
3
Discussion List
4
Survey
5
Issue List

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

Type of list
TemplateId
FeatureId 
 Generic List

100

00BFEA71-DE22-43B2-A848-C05709900100

 Document Library

101

00BFEA71-E717-4E80-AA17-D0C71B360101

 Survey

102

00BFEA71-EB8A-40B1-80C7-506BE7590102

 Links List

103

00BFEA71-2062-426C-90BF-714C59600103

 Announcements List

104

00BFEA71-D1CE-42de-9C63-A44004CE0104

 Contacts List

105

00BFEA71-7E6D-4186-9BA8-C047AC750105

 Events List

106

00BFEA71-EC85-4903-972D-EBE475780106

 Tasks List

107

00BFEA71-A83E-497E-9BA0-7A5C597D0107

 Discussion List

108

00BFEA71-6A49-43FA-B535-D15C05500108

 Picture Library

109

00BFEA71-52D4-45B3-B544-B1C71B620109

 Data Sources

110

00BFEA71-F381-423D-B9D1-DA7A54C50110

 Site template gallery

111



 User Information List

112



 Web Part gallery

113



 List Template gallery

114



 XML Form Library

115

00BFEA71-1E1D-4562-B56A-F05371BB0115

 Master Pages gallery

116



 No-Code Workflows

117

00BFEA71-F600-43F6-A895-40C0DE7B0117

 Custom Workflow Process

118

00BFEA71-2D77-4A75-9FCA-76516689E21A

 Wiki Page Library

119

00BFEA71-C796-4402-9F2F-0EB9A6E71B18

 Grid List

120

00BFEA71-3A1D-41D3-A0EE-651D11570120

 Data Connection Library

130

00BFEA71-DBD7-4F72-B8CB-DA7AC0440130

 Workflow History

140

00BFEA71-4EA5-48D4-A4AD-305CF7030140

 Gantt Task List

150

00BFEA71-513D-4CA0-96C2-6A47775C0119

 Meeting Series List

200



 Meeting Agenda List

201



 Meeting Attendees List

202



 Meeting Decision List

204



 Meeting Objectives List

207



Meeting Things to Bring List

211



 Meeting Workspace Pages List

212



 Blog Posts List

301



 Blog Comments List

302



 Blog Categories List

303



 Status Indicator (KPI) List

432

7ED6CD55-B479-4EB7-A529-E99A24C10BD3

 Report Library

433

6E53DD27-98F2-4AE5-85A0-E9A8EF4AA6DF

 Publishing Pages Library

850



 Issue Tracking List

1100

00BFEA71-5932-4F9C-AD71-1557E5751100

 Administrator Tasks List

1200



 Translation Management Library

1300

29D85C25-170C-4df9-A641-12DB0B9D4130

 Translation List

1301

29D85C25-170C-4df9-A641-12DB0B9D4130

Slide Library

2100