This PowerShell Script restores all the database files with file name extension *.bak from a folder to a SQL Server Instance. We can automate this procedure with the Windows Task Scheduler. To do this we must follow the next steps.




Download and install SQL Server powershell module


#Check if SQL Server module is installed 
Get-Module -Name SqlServer -ListAvailable 
#SQL Server module installation 
Install-Module -Name SqlServer 
#If previous versions are installed we must use the "-AllowClobber" parameter 
Install-Module -Name SqlServer -AllowClobber

Step 1. Download the SQL_Server_Restore_Databases.ps1

Step 2. Create a new on the Windows Task Scheduler.



Step 3.  In the actions tab, select New Action and fill the following settings.




Related Links