Created
November 21, 2017 11:52
-
-
Save phaniav/8079beaa7dace6035691fad1d831ff18 to your computer and use it in GitHub Desktop.
sample script to take a sql server database backup using powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-Location "SQLSERVER:\SQL\Computer\Instance\Databases" | |
SQLSERVER:\SQL\Computer\Instance\Databases> ForEach($database in (Get-ChildItem)) { | |
$dbName = $database.Name | |
Backup-SqlDatabase -Database $dbName -BackupFile "\\mainserver\databasebackup\$dbName.bak" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment