used below script to add the databases DBtools,Test,proddb1 to the Avalialbility group AG_UAT
Add-DbaAgDatabase -SqlInstance primarynode1 -AvailabilityGroup AG_UAT -Database DBtools,Test,proddb1 -SharedPath \\sharedfolder\SQLBackup
used below script to add the databases DBtools,Test,proddb1 to the Avalialbility group AG_UAT
Add-DbaAgDatabase -SqlInstance primarynode1 -AvailabilityGroup AG_UAT -Database DBtools,Test,proddb1 -SharedPath \\sharedfolder\SQLBackup
migration is a simple task with the DBAtools, it will copy all server level objects, jobs, logins, databases with the single click. i used below script to migrate the SQL
$param =@{
source = “sourceServer-PRDB01”
destination = “destServer-PRDB01”
sharedpath =”\168.168.63.8\yogi\Migration_folder”
backuprestore =$true
force=$true
}
Start-DbaMigration @param -Verbose
I have tried different scripts to transfer the logins with permissions, in all of that I like the DBATools command (Export-DBAlogin). which is easy and simple. If DBATools is not installed on your machine, you can do that offline with simple steps
$env:PSModulePath (type $env:PSModulePath at the prompt and press enter). This will allow PowerShell to autoload the module, saving you from having to Import-Module each time you start a new session.once the installation is completed, use below command to export the logins.
Export-dbalogin -sqlinstance servername -filepath ‘filepath’
— if you see execution policy-related errors while importing the DBATools module, try below one
set-executionpolicy -scope process -executionpolicy bypass
import-module DBATools