SharePoint 2016 Managing Farm Configuration PowerShell( Real World example)

This article is a sequence of real world examples of the using PowerShell in SharePoint 2016. In this article, we will discuss how we will use the PowerShell cmdlets to managing the Farm configuration in SharePoint 2016. We will try to cover all the available cmdlets i.e. Get, Set, New, Remove, Start

Scenario:

New SharePoint administrator joins the KrossFarm and his 1st assignment is, Join new server to a farm and move the central admin web app on that server. He also needs to set the WorkflowBatch Size from 100 to 200. Things he learned, they don’t know the passphrase of that farm. Also don’t know about the farm admin account.  At then end, they also ask him to give the list of all available template which is compatibility level 15.

Task:

  • Get the farm configuration
  • Get farm admin account Change the passphrase
  • Create new CA
  • remove the CA
  • Get Web templates list

Get

Let’s start, first, I want to get the farm configuration, for this we have to use the below command. 

Get-SPFarmConfig

This example returns the settings for all global properties  of the farm, The Output will be like this.

Set:

Now I want to change the WorkFlowBatchSize from 100 to 200. For this, we have to run the below script.

$fc = Get-SPFarmConfig
$fc.WorkflowBatchSize = 200
$fc | Set-SPFarmConfig
$fc | Select WorkflowBatchSize | Format-List

Store the Farm configuration in a parameter $fc, then set the value 200  followed by a set command. At the end, we run the command to check the value.

This example will set the **workflowBatchSize **value to 200. The output will be likely this:

Set PassPhrase

As we don’t know about the passphrase, let’s use the below script to change it. Please make sure you documented it properly this time :).

$passphrase=ConvertTo-SecureString -asPlainText -Force
Set-SPPassPhrase -PassPhrase $passphrase -Confirm

This example asks for a passphrase string and sets the farm passphrase to a new value. something looks like this:

Create New Central Admin

 Now we have to

Remove Central Admin

Now we have to remove the ca from the old server.

Set the Central Admin Start-AdminJob

As we Know, Admin job is hanged. So we will run the below command to start the admin job on the server.

Start-SPadminjob

This command will run all the waiting jobs immediately.output will be likely this.

Start-SPadminjob -verbose

This command will run all the waiting jobs immediately and show the verbose output, like this:

See Also