Introduction

Let's walk through the cmdlets which are available in SharePoint 2016 RTM for managing databases. With the release of SharePoint 2016, Microsoft introduced three new cmdlets for managing the AlwaysOnGroup. Now with the help of these new cmdlets, SharePoint administrator can manage the Availability group on AlwaysOn database.

Here are the list of commands:

  • Get-AvailabilityGroupStatus
  • Add-DatabaseToAvailabilityGroup
  • Remove-DatabaseFromAvailabilityGroup
  • Dismount-SPContentDatabase
  • Mount-SPContentDatabase
  • Test-SPContentDatabase

Get-AvailabilityGroupStatus

This command will return all available availability groups which are known to SharePoint farm. i.e.

Get-AvailabilityGroupStatus -Identity krossfarmGroup

This example returns an availability group named KrossFarmGroup.

Add-DatabaseToAvailabilityGroup

This command will use to add the database(s) from a SharePoint farm into an availability group on the SQL Server. i.e.

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

This example adds an availability group named KrossFarmgroup to the KF-ContentDB content database:

  • AGName (Required) The name of the availability group from which the databases are being added.
  • DatabaseName (Required) The name of the database to be added to the availability group.
  • FileShare ( Optional) When a database is being added to the availability group, backup / restore are done from this location to propagate the database to all replicas.

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

This example removes the KrossfarmGroup availability group from the KF_contentDB content database:

  • AGName (Required) The name of the availability group from which the databases are being added.
  • DatabaseName (Required) The name of the database to be added to the availability group.
  • Force(Optional) System.Management.Automation.SwitchParameter Forces a remove from the group.
  • KeepSecondaryData(Optional) SwitchParameter Specifies that copies of the databases on the replicas in the availability group will not be deleted. Otherwise, those database copies will be dropped.