Tag Archive for SharePoint

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 for SharePoint 2013
Add-Type -AssemblyName "Microsoft.SharePoint, Version=, 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)  
		$db.Shrink(20, [Microsoft.SqlServer.Management.Smo.ShrinkMethod]'TruncateOnly')
		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!

Workflow App Permissions

With the new 2013 workflows there are a few scenarios that can cause issues which may not be obvious to those coming from 2010. One such scenario is configuring list items to have Create and Edit access set to Create items and edit items that were created by the user and have a user who did not create the item initiate a 2013 workflow. By default, this will result in the workflow failing due to unauthorised access exceptions.

Lets walk through the scenario in more detail.

Start with creating a new custom list and then in SharePoint Designer, publish a simple List workflow to it.

Publish SPD Workflow

As you can see, a very simple workflow 🙂

Configure the list to allow users to only edit items that they created.

List Permissions
Read more

Fine Grained Permissions in 2013

Setting item level permissions was straight forward in SharePoint 2010, you selected the items you wanted to break inheritance on and selected the Permissions item. When moving to SharePoint 2013 and trying to do the same thing, to a lot of users this functionality appears to no longer exist. Worry not!

To set item level permissions for an item (or multiple items) select the candidate items and switch to the Items tab in the ribbon.

Shared With

Notice the ribbon item called Shared With. This is what replaces the Permissions item from 2010. Click it and a list of users that the item is shared with loads.
Read more

Configuring SQL Server Whitepaper

I recently came across the following whitepaper for configuring SQL Server to get the best performance from it when used in a SharePoint environment.

Download it from here
Or view it from here

Lots of good information in it and well worth keeping to refer to when building SharePoint environments 🙂

Create Site Collection with Content Database

A PowerShell related post today.

If you need to create a new site collection and ensure it uses a specific content database, this little script will get that done for you. No messing about in Central Administration disabling content databases and all that good stuff, just a simple script that gets the job done, hassle free.

$hostIP = $ENV:ComputerName
$hostURL = "http://$hostIP/sites/Site Collection Name"
$user = [Security.Principal.WindowsIdentity]::GetCurrent().Name
$dbServer = "$hostIP"
$contentDbName = "Your_Content_Db_Name"
$webAppName = "SharePoint - 80"
$lcid = 1033
$templateName = "STS#0"
$siteName = "Site Collection Name"
function Add-Site {
	Write-Host ("Creating new ComplianceSP site '", $siteName, "' at ", $hostURL -join "") -NoNewline
	$newSite = New-SPSite $hostURL -OwnerAlias $user -name $siteName -Template $templateName -Language $lcid -ContentDatabase $contentDbName
	$newSite.RootWeb.CreateDefaultAssociatedGroups($newSite.Owner, $null, $null)
	Write-Host " - Done." -ForegroundColor Green
function Add-ContentDatabase {
	$contentDatabase = Get-SPContentDatabase -WebApplication $webAppName | Where { $_.Name -eq $contentDbName }
	if ($contentDatabase -eq $null) {
		Write-Host ("Creating new content database '", $contentDbName, "' in '", $dbServer, "' for web application '", $webAppName, "'" -join "") -NoNewline
		New-SPContentDatabase -Name $contentDbName -DatabaseServer $dbServer -WebApplication $webAppName -MaxSiteCount 1 -WarningSiteCount 0 -Confirm:$false
		Write-Host " - Done." -ForegroundColor Green
	else {
		Write-Host ("Content database '", $contentDbName, "' in '", $dbServer, "' associated with web application '", $webAppName, "' already exists." -join "") -NoNewline
try {
catch {
	Write-Host ""
	Write-Host "Error : " $Error[0] -ForegroundColor Red
	Exit 1

Lets walk through the code.
Read more


Get every new post delivered to your Inbox

Join other followers: