cnromaine
9/8/2013 - 4:49 PM

From http://blah.winsmarts.com/2013-9-Powershell_Script_to_restore_bunch_of_SQL_databases.aspx

$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    
  }