Introduction

I will walk through the cmdlets which are available in SharePoint 2016 RTM TO manage the databases. With the release of SharePoint 2016, Microsoft introduced 3 new cmdlets to manage the AlwaysOn group. Now, with the help of new cmdlets, the SharePoint administrator can manage the Availability group on AlwaysOn database. With the new commands, we can check the status of the AG group, add the database to AG group or remove the database. Moreover, you can even fail DBServer from primary to secondary.

Here is the list of commands given below.

Prior to starting, make sure that a shared location is created on SQL Server, which is accessible from both the primary and secondary group. Also, configure a SharePoint Farm admin account & install an account which has read & write access to that shared location.

Another thing you have to configure is the Always-On group on SQL Server before using these commands. You can't create the Always-On group via these commands.

Get-AvailabilityGroupStatus

This command will return all the available Availability Groups, which are known as SharePoint Farm.

Get-AvailabilityGroupStatus -Identity krossfarmGroup

This example returns an Availability Group named KrossFarmGroup. It will show all the information related to Always-On group which is a current primary Server.

Add-DatabaseToAvailabilityGroup

This command is used to add the database(s) from a SharePoint Farm into an Availability Group on the SQL Server.

Add-DatabaseToAvailabilityGroup -AGName KrossFarmgroup -DatabaseName KF-ContentDB -FileShare \\backup\share\

This example adds an Availability Group named KrossFarmgroup to the KF-ContentDB content database.

Remove-DatabaseFromAvailabilityGroup

This command will remove one or more SharePoint databases from an Availability Group in SQL Server.I.e

Remove-DatabaseFromAvailabilityGroup -AGName KrossFarmgroup -DatabaseName KF_ContentDB -force

This example removes KrossfarmGroup Availability Group from the KF_contentDB content database.

If you want to remove all the databases from the AlwaysOn group, you can use the ProcessAllDatabases parameters.

Note

If you manually add the databases to Always-On group, you will not get anything via this command. Make sure to add all SharePoint databases to Availability Group, using these commands.