Restore multiple SQL databases in one go

Say you want to move some hundred SQL databases onto a new SQL server without a lot of boring manual work.

A nice Powershell script is published at Technet:

https://gallery.technet.microsoft.com/scriptcenter/SQL-Server-Auto-Restore-08d8c77f

remember to:

remove the -norecovery switch at the end of the script

import-module SQLPS

Example, run the script like this:

.\restoreSQL.ps1 "D:\Backup" "<yourSQLinstance>" "D:\Data" "E:\Logs"

I’ve successfully tested this on SQL 2016 and 2017

More articles

Optional features

Check available optional features: DISM /Online /Get-Capabilities Install an optional feature: DISM /Online /Add-capability /capabilityname:Media.MediaFeaturePack~~~~0.0.1.0

Read More »

AD retention period

Check AD retention tombstone value: Import-Module ActiveDirectory $ADForestconfigurationNamingContext = (Get-ADRootDSE).configurationNamingContext $DirectoryServicesConfigPartition = Get-ADObject -Identity “CN=Directory Service,CN=Windows NT,CN=Services,$ADForestconfigurationNamingContext” -Partition $ADForestconfigurationNamingContext -Properties *

Read More »