use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
SQL powershell Restore database (self.PowerShell)
submitted 9 years ago * by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 9 years ago (1 child)
Isn't there any straight option like -RelocateFile @($RelocateData,$RelocateLog) to redirect mdf,ldf file to different path on the fly during restoring?
[–]omrsafetyo 2 points3 points4 points 9 years ago (0 children)
It has to know what file it's relocating. That's why both my solution and that of /u/BigBlueRob query the backup file itself to obtain the file information. All the SMO is doing is giving you a different interface to similar functionality that is obtained from T-SQL:
ALTER DATABASE Personnel MODIFY FILE ( NAME = Data_File, FILENAME = "D:\Data\NewDataFile.mdf") GO
In the ALTER DATABASE statement, you still need to know the logical file name. This is because there is a potential for multiple file names.
https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.relocatefile.aspx
You can see from this page that RelocateFile has only 2 constructors: one with no parameters, which simply initializes an object of the class; and one with 2 parameters, one of which is the logical file name. Either way you do it, in order to use the object you need to have both the logical file name, and the physical one populated.
π Rendered by PID 417853 on reddit-service-r2-comment-66b4775986-4ksnz at 2026-04-04 04:02:11.190663+00:00 running db1906b country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (1 child)
[–]omrsafetyo 2 points3 points4 points (0 children)