I'm looking for a script to restore a SQL Server 2005 backup. Ideally the script will have the following features

  • handle backup files on a network location
  • Handle different file structure of source and destination server ("With MOVE"?)
  • Written in PowerShell

Any suggestions?

  • I'm curious why you want to use PowerShell to run a SQL Command, when the Native T/SQL command will probably be easier to find and use?
    – mrdenny
    Commented Aug 3, 2009 at 19:33

3 Answers 3


Here's a link to a script I created


I'm using link text. Ok, is not really a Powershell script. But it works on all Servers, 2000 or 2005 so far. And it does a great job for me. Just executing master..usp_build_restore_script and copy the relevant part for the Restore.

I did also an extension in Powershell. As a sample, before i execute a Restore, i like to see if the necessary files really exists or not. For this i just execute the master..usp_build_restore_script from Powershell and use test-path on all Backupfiles.


Not sure about the different structures but this post at sqlmusings.com should be agood starting point for you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .