Skip to content

Instantly share code, notes, and snippets.

@spy86
Created August 3, 2017 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spy86/466884b018a39991c30739cc864fb1d5 to your computer and use it in GitHub Desktop.
Save spy86/466884b018a39991c30739cc864fb1d5 to your computer and use it in GitHub Desktop.
PS drop database & close connection
$dbnamefile1 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name")
$dbname1 = "DB-Name"
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1"
$dbnamefile2 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name")
$dbname2 = "DB-Name"
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1"
$dbnamefile3 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name")
$dbname3 = "DB-Name"
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1"
$dbnamefile4 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name")
$dbname4 = "DB-Name"
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1"
$dbnamefile5 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name")
$dbname5 = "DB-Name"
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1"
$dbnamefile6 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name")
$dbname6 = "DB-Name"
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1"
$dbnamefile7 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name")
$dbname7 = "DB-Name"
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1"
$dbnamefile8 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name")
$dbname8 = "DB-Name"
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment