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
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:
<fieldref Name="Country"></fieldref><values><value Type="LookupMulti">Scotland</value></values>
<fieldref Name="Country"></fieldref><values><value Type="LookupMulti">England</value></values>
<fieldref Name="Country"></fieldref><values><value Type="LookupMulti">Wales</value></values>
<fieldref Name="Country"></fieldref><values><value Type="LookupMulti">Ireland</value></values>
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!
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.
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 188.8.131.52 for SharePoint 2013
Add-Type -AssemblyName "Microsoft.SharePoint, Version=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
# Reset the content index
# 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)
Write-Host "$dbName has been shrunk"
Write-Host "$dbName does not exist"
Comments in the script should make this one clear to understand, happy coding!
Happy Christmas and a prosperous New Year to all! 🙂