Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$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
You can’t perform that action at this time.