<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell</title>
	<atom:link href="http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/</link>
	<description>ramblings, discoveries, tutorials on sql server and other database stuff</description>
	<lastBuildDate>Wed, 25 Jan 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: kofco</title>
		<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/comment-page-1/#comment-5966</link>
		<dc:creator>kofco</dc:creator>
		<pubDate>Tue, 29 Nov 2011 22:36:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/?p=809#comment-5966</guid>
		<description>Very helpful!
for the logical name this works:

# Get the file list from backup file
$dbFileList = $smoRestore.ReadFileList($server)
$smoRestoreFile.LogicalFileName = $dbFileList.Select(&quot;Type = &#039;D&#039;&quot;)[0].LogicalName

$smoRestoreLog.LogicalFileName = $dbFileList.Select(&quot;Type = &#039;L&#039;&quot;)[0].LogicalName

Thanks</description>
		<content:encoded><![CDATA[<p>Very helpful!<br />
for the logical name this works:</p>
<p># Get the file list from backup file<br />
$dbFileList = $smoRestore.ReadFileList($server)<br />
$smoRestoreFile.LogicalFileName = $dbFileList.Select(&#8220;Type = &#8216;D&#8217;&#8221;)[0].LogicalName</p>
<p>$smoRestoreLog.LogicalFileName = $dbFileList.Select(&#8220;Type = &#8216;L&#8217;&#8221;)[0].LogicalName</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adrian</title>
		<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/comment-page-1/#comment-5876</link>
		<dc:creator>adrian</dc:creator>
		<pubDate>Thu, 01 Sep 2011 19:10:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/?p=809#comment-5876</guid>
		<description>This is pure gold. Excellent. This has automated refresh of PROD to TEST to DEV. Outstanding.</description>
		<content:encoded><![CDATA[<p>This is pure gold. Excellent. This has automated refresh of PROD to TEST to DEV. Outstanding.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Schellenberg</title>
		<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/comment-page-1/#comment-5734</link>
		<dc:creator>Jim Schellenberg</dc:creator>
		<pubDate>Sat, 04 Dec 2010 03:29:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/?p=809#comment-5734</guid>
		<description>I&#039;m looking for a script that can be pointed to a directory that contains a full backup, perhaps a differential backup as well and many transaction log backups and do a recovery to a point in time or to the end of the logs. If a differential backup is involved then the use of the logs could be limited to after the differential backup.

Has anyone given this a go?</description>
		<content:encoded><![CDATA[<p>I&#8217;m looking for a script that can be pointed to a directory that contains a full backup, perhaps a differential backup as well and many transaction log backups and do a recovery to a point in time or to the end of the logs. If a differential backup is involved then the use of the logs could be limited to after the differential backup.</p>
<p>Has anyone given this a go?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/comment-page-1/#comment-5676</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Tue, 02 Nov 2010 10:43:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/?p=809#comment-5676</guid>
		<description>To kill connections to the database to get exclusive access before restoring add this line:

$server.KillAllprocesses($dbname)</description>
		<content:encoded><![CDATA[<p>To kill connections to the database to get exclusive access before restoring add this line:</p>
<p>$server.KillAllprocesses($dbname)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart Hayes</title>
		<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/comment-page-1/#comment-5675</link>
		<dc:creator>Bart Hayes</dc:creator>
		<pubDate>Tue, 02 Nov 2010 06:44:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/?p=809#comment-5675</guid>
		<description>How do you obtain restore details when the backup files have been copied from another server? I&#039;m getting an error on the line
$smoRestoreDetails = $smoRestore.ReadBackupHeader($server). I think because object &#039;$server&#039; is created from the current server but that won&#039;t know anything about a backup file from another server will it?</description>
		<content:encoded><![CDATA[<p>How do you obtain restore details when the backup files have been copied from another server? I&#8217;m getting an error on the line<br />
$smoRestoreDetails = $smoRestore.ReadBackupHeader($server). I think because object &#8216;$server&#8217; is created from the current server but that won&#8217;t know anything about a backup file from another server will it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blog Post: PowerShell: Restoring a whole heap of SQL Databases &#124; IT.beta</title>
		<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/comment-page-1/#comment-5621</link>
		<dc:creator>Blog Post: PowerShell: Restoring a whole heap of SQL Databases &#124; IT.beta</dc:creator>
		<pubDate>Sun, 22 Aug 2010 17:48:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/?p=809#comment-5621</guid>
		<description>[...] about 500 databases from their production environment to a development/staging environment.&#160; He found this script that should theoretically get the job done but he was running into a few proble....&#160; The problems he was encountering were mostly related to different drive mappings and [...]</description>
		<content:encoded><![CDATA[<p>[...] about 500 databases from their production environment to a development/staging environment.&#160; He found this script that should theoretically get the job done but he was running into a few proble&#8230;.&#160; The problems he was encountering were mostly related to different drive mappings and [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Will Seitz</title>
		<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/comment-page-1/#comment-5620</link>
		<dc:creator>Will Seitz</dc:creator>
		<pubDate>Mon, 16 Aug 2010 12:57:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/?p=809#comment-5620</guid>
		<description>I had some problems with the way you got the logical name. I used instead:

&lt;code&gt;
$smoRestoreDetails = $smoRestore.ReadFileList($targetServer)
$sourceDb = $smoRestoreDetails.Rows[0][&quot;LogicalName&quot;] 
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I had some problems with the way you got the logical name. I used instead:</p>
<p><code><br />
$smoRestoreDetails = $smoRestore.ReadFileList($targetServer)<br />
$sourceDb = $smoRestoreDetails.Rows[0]["LogicalName"]<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Woody</title>
		<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/comment-page-1/#comment-5609</link>
		<dc:creator>Woody</dc:creator>
		<pubDate>Thu, 29 Jul 2010 17:15:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/?p=809#comment-5609</guid>
		<description>Absolutely great script! This has really come in handy for me. Thanks so much for sharing it. Can I make a couple of suggestions for Restore to New Database? 
1) When determining the Data and file locations you might want to use $server.DefaultFile and $server.DefaultLog. Using $server.Information.MasterDBPath and $server.Information.MasterDBLogPath points to the location of the files for &#039;master&#039; and not necessarily the location of &#039;user&#039; databases.
2) Consider using $DataFiles = $restore.ReadFileList($server) to get the actual Logical file names. Attempting to restore to a constructed logical name, which may be incorrect, results in a restore error.

All in all, still a very helpful script!</description>
		<content:encoded><![CDATA[<p>Absolutely great script! This has really come in handy for me. Thanks so much for sharing it. Can I make a couple of suggestions for Restore to New Database?<br />
1) When determining the Data and file locations you might want to use $server.DefaultFile and $server.DefaultLog. Using $server.Information.MasterDBPath and $server.Information.MasterDBLogPath points to the location of the files for &#8216;master&#8217; and not necessarily the location of &#8216;user&#8217; databases.<br />
2) Consider using $DataFiles = $restore.ReadFileList($server) to get the actual Logical file names. Attempting to restore to a constructed logical name, which may be incorrect, results in a restore error.</p>
<p>All in all, still a very helpful script!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

