Wednesday, March 25, 2015

Search for SharePoint Foundation 2013 using PowerShell

How to create and configure Search Service Application for SharePoint Foundation using PowerShell? Here is a solution.


Change in script:

Name of Server.

Name of Search Service Application.

To find name of Service Application Pool use next command Get-SPServiceApplicationPool.
You get one of next Service Appliction Pool:
"SharePoint Web Services System"   "SharePoint Web Services Default"










Change Application Pool in script for $svcPool and $adminPool.


Script:

#Start the search service instance on the server
Get-SPEnterpriseSearchServiceInstance -Local | Start-SPEnterpriseSearchServiceInstance
$serverName="SAVA"
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance -Identity $serverName

#Give a unique name to your search service application
$serviceAppName = "Search Service Application"

#Get the application pools to use (make sure you change the value for your environment)
$svcPool = Get-SPServiceApplicationPool "SharePoint Web Services Default"
$adminPool = Get-SPServiceApplicationPool "SharePoint Web Services Default"

#Get the service from the service instance so we can call a method on it
$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance –Local
$searchService = $searchServiceInstance.Service

#Define your unique DB names without the guids
$adminDB = "Search_Service_Application_DB"
$propertyStoreDB = "Search_Service_Application_PropertyStoreDB"
$crawlStoreDB = "Search_Service_Application_CrawlStoreDB"
$analysticsStoreDB = "Search_Service_Application_AnalyticsStoreDB"
$linkStoreDB = "Search_Service_Application_LinkStoreDB"

#Since this method takes in the value of object type Microsoft.SharePoint.Administration.SPDatabaseParameters we will
create these from our clean DB names
$adminDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($adminDB,"None")
$propertyDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters
($propertyStoreDB,"None")
$crawlStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters
($crawlStoreDB,"None")
$analyticsStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters
($analysticsStoreDB,"None")
$linkStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($linkStoreDB,"None")

#Create the search service application by calling the function
$searchServiceApp = $searchService.CreateApplication($serviceAppName, $adminDBParameters, $propertyDBParameters,
$crawlStoreDBParameters, $analyticsStoreDBParameters, $linkStoreDBParameters,
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$svcPool,
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$adminPool)

#Create the search service application proxy as usual (luckily PowerShell for this works and is bot blocked)
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName Proxy" -SearchApplication
$searchServiceApp
#Provision the search service application
$searchServiceApp.Provision()



At this point the search service application will be provisioned without any topology components. Active topology using next script.



#Now we will call the method to initiate the default topology component creation using reflection
$bindings = @("InvokeMethod", "NonPublic", "Instance")
$types = @([Microsoft.Office.Server.Search.Administration.SearchServiceInstance])
$values = @([Microsoft.Office.Server.Search.Administration.SearchServiceInstance]$searchServiceInstance)
$methodInfo = $searchServiceApp.GetType().GetMethod("InitDefaultTopology", $bindings, $null, $types, $null)
$searchTopology = $methodInfo.Invoke($searchServiceApp, $values)



Now you need some patience while all the components spring to life behind the scenes. This can take some time depending how robust your environment is.






Wednesday, March 11, 2015

Displaying Promoted Links on Multiple Lines SharePoint

When you use the SharePoint "Promoted Links" web part on one of your pages, there is the possibility that the web part uses a lot of horizontal space because you need to display a large number of tiles.










Firstly, you’ll need to upload the JavaScript. You can download the JavaScript from here.
It is important to upload the JavaScript file to the Site Collection Master Page gallery, in the Display Templates folder.

  1. Go to the Settings > Site Settings.
  2. Click “Master Pages”
  3. Click “Display Templates”
  4. Upload the file, ensuring it is called “MultilinePromotedLinks.js”














Next, edit the web part, and scroll to the “JSLink” property, under “Miscellaneous”. Paste in JSLink property “~sitecollection/_layouts/15/sp.init.js|~sitecollection/_catalogs/masterpage/display templates/MultilinePromotedLinks.js”.







































 Apply the changes to your web part, and save the changes.