Skip navigation
SharePoint How-To Series: Administration

SharePoint How-To Series: Administration

In this post we will work though the core administration of the SharePoint Service Applications.

SharePoint as a core product has had its technology stack updated multiple times. From the days of using the same storage as the Exchange product to now utilizing SQL Server, many things have changed. One thing that hasn’t changed, though, is the need to administer SharePoint. Understanding how the various parts of the platform fit together, its features, components and the underlying technology stack will help you to more effectively administer SharePoint.

In this post we will work though the core administration of the SharePoint Service Applications. As you may remember, Service Applications enable SharePoint to scale its features and services. Each Service Application is composed of various services, including Web services, as well as a database and an administration component.

As an example, let’s take a look at what the Search Service Application is made up of.

Although “stsadm” is still available in SharePoint 2013, we’re going to use “PowerShell” to provision the Search Service Application.

First, we need to make sure that we have loaded the SharePoint PowerShell snap-in.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Now we need to set some variable values for the core configuration.

$SearchIndexLocation = "D:\SharePoint\Data\Search”

$SearchAppPoolName = "Search Service Application Pool"

$SearchAppPoolAccountName = "DOMAIN\user"

$SearchServerName = (Get-ChildItem env:computername).value

$SearchServiceName = "Search Service Application"

$SearchServiceProxyName = "Search Service Application Proxy"

$SearchDatabaseName = "SEARCH"

Once we have the variables set, we can then perform checks for the application pool and ensure that the core Enterprise Search Services are started.

$SearchAppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue

 

if (!$SearchAppPool)

{

    $SearchAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose

}

 

Start-SPEnterpriseSearchServiceInstance $SearchServerName -ErrorAction SilentlyContinue

Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchServerName -ErrorAction SilentlyContinue

 

Now we have set variables, we check for a Search Service Application already existing with the same name, if not we go ahead and create it.

 

$ServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceName -ErrorAction SilentlyContinue

 

if (!$ServiceApplication)

{

    $ServiceApplication = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $SearchAppPool.Name 

-DatabaseName $SearchDatabaseName

}

 

$Proxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceProxyName -ErrorAction SilentlyContinue

 

if (!$Proxy)

{

    New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication

}

 

Finally, we activate the new Topology.

 

$ServiceApplication.ActiveTopology

 

To compete the process, we need to clone the existing Topology and make any changes we need, such as multiple servers or specific search roles. For a basic single server setup, we would use the following:

 

$SearchClone = $ServiceApplication.ActiveTopology.Clone()

$SearchServiceInstance = Get-SPEnterpriseSearchServiceInstance -local

New-SPEnterpriseSearchAdminComponent –SearchTopology $SearchClone -SearchServiceInstance $SearchServiceInstance

New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $SearchClone -SearchServiceInstance $SearchServiceInstance

New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $SearchClone -SearchServiceInstance $SearchServiceInstance

New-SPEnterpriseSearchCrawlComponent –SearchTopology $SearchClone -SearchServiceInstance $SearchServiceInstance

 

Remove-Item -Recurse -Force -LiteralPath $SearchIndexLocation -ErrorAction SilentlyContinue

mkdir -Path $SearchIndexLocation -Force

 

New-SPEnterpriseSearchIndexComponent –SearchTopology $SearchClone -SearchServiceInstance $SearchServiceInstance -RootDirectory $SearchIndexLocation

New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $SearchClone -SearchServiceInstance $SearchServiceInstance

$SearchClone.Activate()

That does it. We should now have a newly created Search Service Application. All Service Applications can be created using PowerShell; the syntax is a little different, but the principle is the same.

PowerShell allows us to perform all kinds of configuration and administration, at all levels of SharePoint--from the Farm through to specific lists and libraries. For example, if we wanted to use PowerShell to count the number of items within a SharePoint Document Library, we would use the following PowerShell.

$SharePointSite = Get-SPWeb “http://url/listorlibrary”

$SharePointList = $ SharePointSite.Lists["ListName"]

 

$SharePointListItems = $ SharePointList.Items.Count

Write-Host "Total Count of Items in List: " $SharePointListItems

We could also go back up the stack and use PowerShell for the creation of Web Applications and Site Collections. To create a Web Application with a custom Application Pool, we can use the following syntax.

First we set some variables for the URL and Application Pool settings.

$SharePointWebAppURL = "http://web-application-url"

$SharePointNewAppPoolName = "Application Pool Name"

$SharePointNewAppPoolUserName = "DOMAIN\user"

Next, we grab the SharePoint Farm, set our password for the account being used as the Application Pool Account, and then create it.

$Farm = Get-SPFarm

$Service = $Farm.Services | where {$_.TypeName -eq "Microsoft SharePoint Foundation Web Application"}

$Password = Read-Host -Prompt "Please enter your password" -AsSecureString

$SharePointNewAppPool = New-Object Microsoft.SharePoint.Administration.SPApplicationPool($SharePointNewAppPoolName,$Service)

$SharePointNewAppPool.CurrentIdentityType = "SpecificUser"

$SharePointNewAppPool.Username = $SharePointNewAppPoolUserName

$SharePointNewAppPool.SetPassword($Password)

$SharePointNewAppPool.Provision()

$SharePointNewAppPool.Update($true)

Finally, we create the new Web Application, with the desired details and newly created Application Pool.

$SharePointNewAppPool = $Service.ApplicationPools[$SharePointNewAppPoolName]

$SharePointWebApp = Get-SPWebApplication $SharePointWebAppURL

$SharePointWebApp.ApplicationPool = $SharePointNewAppPool

$SharePointWebApp.Update()

$SharePointWebApp.ProvisionGlobally()

As you can see,PowerShell can be used for all aspects of SharePoint Administration. PowerShell comes into its own when you need to build a new SharePoint Farm. Using a scripted process allows for repeatable, tried-and tested-deployments, which will make the life of an administrator simpler. If we wanted to create a SharePoint Farm, we could use the “psconfig” Graphical User Interface or PowerShell. The PowerShell would look similar to this:

SharePoint 2013

$SharePointDatabaseServer = "SQL Server";

$SharePointFarmName = "SHAREPOINT";

$SharePointConfigDatabase = $FarmName+"_CONFIG";

$SharePointAdminContentDatabase = $FarmName+"_ADMIN_CONTENT";

$SharePointPassphrase = convertto-securestring "Pass@word1" -asplaintext -force;

$SharePointCentralAdminPort = "9999";

$SharePointCentralAdminAuthentication = "NTLM";

$SharePointFarmAccount = "DOMAIN\user"

 

New-SPConfigurationDatabase -DatabaseName $SharePointConfigDatabase -DatabaseServer $SharePointDatabaseServer -FarmCredentials (Get-Credential $SharePointFarmAccount) -Passphrase $SharePointPassphrase –AdministrationContentDatabaseName $SharePointAdminContentDatabase

Install-SPHelpCollection -All

Initialize-SPResourceSecurity

Install-SPService

Install-SPFeature -AllExistingFeatures

New-SPCentralAdministration -Port $SharePointCentralAdminPort

Install-SPApplicationContent

SharePoint 2016 has the additional “localservervrole” parameter, which can be populated with the following values. (So, our PowerShell needs to change a little.)

WebFrontEnd

Application

SingleServer

SingleServerFarm

DistributedCache

Search

SpecialLoad

Custom

 

SharePoint 2016

New-SPConfigurationDatabase -DatabaseName $SharePointConfigDatabase -DatabaseServer $SharePointDatabaseServer -FarmCredentials (Get-Credential $SharePointFarmAccount) -Passphrase $SharePointPassphrase -AdministrationContentDatabaseName $SharePointAdminContentDatabase -localserverrole SingleServerFarm

Install-SPHelpCollection -All

Initialize-SPResourceSecurity

Install-SPService

Install-SPFeature -AllExistingFeatures

New-SPCentralAdministration -Port $SharePointCentralAdminPort

Install-SPApplicationContent

Coming Next:

In the next post, we will build on what we've done here to help you administer SharePoint.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish