Skip to content

Instantly share code, notes, and snippets.

@cnromaine
Created September 8, 2013 16:49
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 cnromaine/6486362 to your computer and use it in GitHub Desktop.
Save cnromaine/6486362 to your computer and use it in GitHub Desktop.
$path = (get-location).path
$files = get-childitem | where {$_.extension -eq ".bak"}
foreach($file in $files)
{
$dbPath = $path + '\' + $file
$dbName = $file.ToString().Replace(".bak", "")
write-host "Adding" $dbPath "to db " $dbName
Restore-SqlDatabase -ServerInstance "writeyourserverinstancehere" -Database $dbName -BackupFile $dbPath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment