May 9, 2012 at 2:55 am
I'm evaluating powershell for my use to restore SQL db.
Backup is from SQL Server 2008R2 db and is being restored on instance 2.
Backup has been copied from share path to local drive.
I have a script with does the restore job but everytime I call it it fails with one or other error.
Can you please share your ideas on any good Restore DB script and a way to execute them using powershell.
May 9, 2012 at 5:17 am
Details on the error(s) do matter !
Did you have a look at :
- http://www.codeproject.com/Articles/110908/SQL-DB-Restore-using-PowerShell
or
- http://www.sswug.org/articles/viewarticle.aspx?id=44909
or
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
May 9, 2012 at 5:40 am
ALZDBA (5/9/2012)
Details on the error(s) do matter !Did you have a look at :
- http://www.codeproject.com/Articles/110908/SQL-DB-Restore-using-PowerShell
or
- http://www.sswug.org/articles/viewarticle.aspx?id=44909
or
Yeah have tried all of these method but none of them is clear in stating if saving a file on C: or other drive how can i call them in powershell or if I have many PS1 file how to tell powershell which to open/Execute.
On top of it, have tried having only one file in C: and executing in powershell but every command has error like
> Invoke-SQLRestore is not recognised as name of cmdlet,function, scripot file.
> when usinh ScriptBlock, cannot validate argument on parameter. The argument is Null
etc etc
I have tried searching answers for above errors and have tried most of them like installing some microsoft sharepoint installer, adding snapins, etc but no luck.
May 9, 2012 at 5:46 am
did you try to execute your package from Powershell_ISE , PowerGUI or PowerSE (which are all free tools)
Which version of powershell / SQLserver are you using ?
Apparently you didn't load the needed modules in your powershell runtime environment;
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
May 9, 2012 at 5:51 am
ALZDBA (5/9/2012)
did you try to execute your package from Powershell_ISE , PowerGUI or PowerSE (which are all free tools)Which version of powershell / SQLserver are you using ?
Apparently you didn't load the needed modules in your powershell runtime environment;
I'm using Powershell_ISE,
Powershell version 2.0, installed on Win 7 x64. SQL Server 2008 R2 SP1
Which modules should I load?
May 9, 2012 at 6:55 am
Have a look at:
- http://msdn.microsoft.com/en-us/library/hh245202.aspx
- http://sqlblog.com/blogs/allen_white/archive/2008/12/07/loading-smo-assemblies-into-powershell.aspx
- http://www.mssqltips.com/sqlservertip/1745/using-powershell-with-sql-server-management-objects-smo/
## load SMO assemblies
## use $null to prevent display of assembly load information
$null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended")
$null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply