July 2018
Beginner
552 pages
13h 18m
English
Using the SqlServer module, it is possible to set up, maintain, and remove SqlAvailability groups. Creating a new SqlAvailability group can be quite complex in T-SQL; however, it is surprisingly simple in PowerShell.
First, we need to establish a connection to both the primary and the secondary instance. This speeds up subsequent calls and ensures both instances are available:
$primaryServer = Get-SqlInstance -MachineName PrimaryComputer -Name Instance$secondaryServer = Get-SqlInstance -MachineName SecondaryComputer -Name Instance
Next, it is necessary to clone the database you want mirrored onto the replica server. For this, you can use Backup-SqlDatabase and Restore-SqlDatabase, as follows:
# Backup database ...
Read now
Unlock full access