This script is used to restore a full backup of an existing database to a server of your choice. If the latest full backup is not found, or if the $newBackup switch is on, a new full backup is created. If the database already exists on the destination server, it will not be replaced.
Before running the script, set the value of the $backupFolder variable to a directory that both the source and destination SQL Server Service accounts can access.
To restore the latest backup to the same server:
.\Restore-LatestBackup.ps1 "DbName" "ServerA" "ServerA" "NewDbName"
To restore a new backup to a different server:
.\Restore-LatestBackup.ps1 "DbName" "ServerA" "ServerB" -newBackup
To use SQL Authentication:
.\Restore-LatestBackup.ps1 "DbName" "ServerA" "ServerB" "NewDbName" -newBackup -sqlAuth "sa" "p4$$w0rd"