Skip to content

Instantly share code, notes, and snippets.

@MikeFal
Last active February 1, 2016 17:48
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 MikeFal/e0038a9ca8be70e2b4f9 to your computer and use it in GitHub Desktop.
Save MikeFal/e0038a9ca8be70e2b4f9 to your computer and use it in GitHub Desktop.
$eomstring = '20160131'
$files = dir C:\Backups\ *.bak | Where-Object {$_.Name -like "*$eomstring*"}
foreach($file in $files){
#Script each restore. Remove Out-File to just restore
Restore-SqlDatabase -ServerInstance localhost -Database $file.Name -BackupFile $file.fullname -Script | Out-File -Append C:\TEMP\EOMRestore.sql
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment