Backup multiple SQL databases using PowerShell

Sviatoslav Bulash -

Run powershell:

 

Import-Module SQLPS -DisableNameChecking
Set-location SQLSERVER:\SQL\{SERVER NAME}\{INSTANCE NAME}\DEFAULT\Databases
$db=get-childitem -force|where name -like '*EB_Demo*'


foreach ($database in $db)
{
$dbname = $database.Name
Backup-SqlDatabase -Database $dbname -BackupFile "C:\backup\$($dbname).bak"
}

Have more questions? Submit a request

Comments

Powered by Zendesk