Restart Services Script

Looking for a PowerShell script to restart important services across a SharePoint farm? Look no further because all you need is here 🙂

The script below, initiated by calling the Restart-Services function, restarts the following services on all SharePoint servers in the farm:

  • SharePoint Timer
  • World Wide Web Publishing Service
  • IIS Admin Service
  • SharePoint Administration

Continue reading

Posted in SharePoint | Tagged , | Leave a comment

Alternate to CAML Or

In is a lesser known CAML operator that I’d like to bring to more peoples attention. When writing CAML and you want to restrict the results by a multi value field equaling two or more values, you’d write something like:

<where>
<or>
  </or><or>
    <eq>
      <fieldref Name="Country"></fieldref><values><value Type="LookupMulti">Scotland</value></values>
    </eq><eq>
    </eq><eq>
      <fieldref Name="Country"></fieldref><values><value Type="LookupMulti">England</value></values>
    </eq><eq>
  </eq></or>
  <or>
    <eq>
      <fieldref Name="Country"></fieldref><values><value Type="LookupMulti">Wales</value></values>
    </eq><eq>
    </eq><eq>
      <fieldref Name="Country"></fieldref><values><value Type="LookupMulti">Ireland</value></values>
    </eq><eq>
  </eq></or>
 
</where>

This will return any item that has the value Scotland, England, Wales or Ireland in the Country field. As the number of values you want to match against grows, imagine the state of the CAML query!
Continue reading

Posted in SharePoint | Tagged , | Leave a comment

SharePoint 2016 On-Premises

With the next version on SharePoint due sometime during the second half of this year, it’s good to hear that Microsoft are still very much continuing to provide an on-premise version. There’s been a lot of chatter recently about this being discontinued but it’s still a kicking and a screaming. See this post from earlier today – Evolution of SharePoint; definitely worth a read.

Posted in SharePoint | Tagged | Leave a comment

Shrink CrawlStore Database

A useful script for running on your dev\uat environments to free valuable disk space. The crawl store database can grow quite significantly over time.

First of all, the PowerShell script:

# Load the SharePoint assembly - change the version to 15.0.0.0 for SharePoint 2013
Add-Type -AssemblyName "Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
 
# Reset the content index
(Get-SPEnterpriseSearchServiceApplication).Reset($true,$true)
 
# Get the database server for the default content service
$dbServer = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DefaultDatabaseInstance.NormalizedDataSource
 
# Get the SQL Management Object server for the content service retrieved above
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
$SMOserver = New-Object ('Microsoft.SqlServer.Management.Smo.Server') -argumentlist $dbServer
 
# Get the search service application instance
$searchServiceApp = (Get-SPEnterpriseSearchServiceApplication)
 
# Iterate the crawl stores and for each database, shrink it in size by 20%
foreach($crawlStore in $searchServiceApp.CrawlStores)
{		
	$dbName = $crawlStore.Name	
	$db = $SMOserver.Databases[$dbName]
	if ($db -ne $null)  
	 {  
		$db.Shrink(20, [Microsoft.SqlServer.Management.Smo.ShrinkMethod]'TruncateOnly')
		Write-Host "$dbName has been shrunk"
	 }
	 else
	 {
		Write-Host "$dbName does not exist"
	 }
}

Comments in the script should make this one clear to understand, happy coding!

Posted in SharePoint, SQL | Tagged , , | Leave a comment

Crimbo

Happy Christmas and a prosperous New Year to all! 🙂

Posted in General | Leave a comment