Scripts-PowerShell For DBA Part-3

Database Backup On Source Server (Copy Only)

Get-DbaDatabase -sqlinstance Localhost -ExcludeAllSystemdb|Backup-DbaDatabase -BackupDirectory C:\Backup\Migration -CreateFolder –Type Full -Copy Only

Restore Database Backup On Destination Server

restore-dbadatabase -sqlserver localhost\SQL2017 -Path C:\Backup\Migration -DestinationDataDirectory D:\Data17 -DestinationLogDirectory E:\Log17
-verbose -WithReplace

Copy Agent Jobs

Copy-DbaAgentJob -Source Localhost -Destination Localhost\SQL2017 -ExcludeJob <job1,job2..> -DisableOnDestination -Force</job1,job2..>

Export Logins

Export-DbaLogin -SqlInstance Localhost -Path C:\backup\logins.sql -Destinationversion SQLServer2017

List Orphan Users

Get-DbadbOrphanUser -SqlInstance Localhost\SQL2017

Repair Orphan Users

Repair-DbaDbOrphanUser -SqlInstance Localhost\SQL2017

Author: Sauras Pandey

Sauras Pandey is an MCP, SQL Server DBA/Architect with 9+ years of experience working in a variety of environments

Leave a Reply

Your email address will not be published.