{"id":55352,"date":"2023-11-13T13:07:03","date_gmt":"2023-11-13T13:07:03","guid":{"rendered":"https:\/\/dbtut.com\/?p=55352"},"modified":"2023-11-13T13:09:29","modified_gmt":"2023-11-13T13:09:29","slug":"how-to-restore-sql-server-database-using-powershell","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/","title":{"rendered":"How To Restore SQL Server Database Using PowerShell"},"content":{"rendered":"<p>In our previous article, we learned how to take a database backup using Powershell&#8217;s dbatools module, and in today&#8217;s article, I will explain how to restore the backup we took using dbatools.<\/p>\n<p>First of all, let&#8217;s learn which commands include restore in DBATools.<\/p>\n<p>To do this, we must run the following command in the powershell console where we run as administrator.<\/p>\n<pre class=\"lang:default decode:true \">Get-Help * Restore *<\/pre>\n<figure style=\"width: 859px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-1-1.png\" alt=\"\" width=\"859\" height=\"1000\" \/><figcaption class=\"wp-caption-text\">Picture-1<\/figcaption><\/figure>\n<p>As we see in the picture above, there is function information we can use, but we will be examining the &#8220;Restore-DbaDatabase&#8221; function in the dbatools module.<\/p>\n<h4>Restore-DbaDatabase<\/h4>\n<p>We can perform SQL database restore operations using this command and the specified backup files.<\/p>\n<p>We have multiple configuration options in this command.<\/p>\n<p>Using the following command, we can get brief information as well as Restore-DbaDatabase information.<\/p>\n<pre class=\"lang:default decode:true \">Get-Help Restore-DbaDatabase<\/pre>\n<p>It gives the following output.<\/p>\n<figure style=\"width: 858px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-2-2.png\" alt=\"\" width=\"858\" height=\"893\" \/><figcaption class=\"wp-caption-text\">Picture-2<\/figcaption><\/figure>\n<p>We had previous backups using DBATools.<\/p>\n<p>Now let&#8217;s perform the restoration using these backups.<br \/>\n(We made a backup in the D:\\SQLBackup\\MSHOWTO\\ folder.)<\/p>\n<figure style=\"width: 461px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-3-2.png\" alt=\"\" width=\"461\" height=\"92\" \/><figcaption class=\"wp-caption-text\">Picture-3<\/figcaption><\/figure>\n<p>Our backups are as above, let&#8217;s check a database list.<\/p>\n<figure style=\"width: 351px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-4-2.png\" alt=\"\" width=\"351\" height=\"179\" \/><figcaption class=\"wp-caption-text\">Picture-4<\/figcaption><\/figure>\n<p>As you can see, there is only a database named MSHOWTO and we have different backups for it.<\/p>\n<p>Let&#8217;s run the Restore-DbaDatabase command by providing the sqlinstance and path information and see what happens.<\/p>\n<pre class=\"lang:default decode:true \">Restore-DbaDatabase -SqlInstance localhost -Path D:\\SQLBackup\\MSHOWTO<\/pre>\n<figure style=\"width: 1281px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-5-2.png\" alt=\"\" width=\"1281\" height=\"154\" \/><figcaption class=\"wp-caption-text\">Picture-5<\/figcaption><\/figure>\n<p>As you can see in the picture above, it gave an error because I wanted to restore an existing database.<\/p>\n<p>You can continue by selecting the &#8220;WithReplace&#8221; option to replace the existing database.<\/p>\n<p>In the screenshot below, you can see that the backup named \u201clocalhost-MSSQLSERVER-MSHOWTO-201906182024.bak\u201d in the path we specified has been restored.<\/p>\n<figure style=\"width: 1265px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-6-2.png\" alt=\"\" width=\"1265\" height=\"360\" \/><figcaption class=\"wp-caption-text\">Picture-6<\/figcaption><\/figure>\n<p>After the SQL Restore process is completed, it gives us a transaction output as you see in Picture-6. (Backup name, database name, database owner and script used, etc.)<\/p>\n<p>In our first example, we restored the existing database using &#8220;withreplace&#8221;, but if we wanted to restore the backup to a different directory, it would be sufficient to run the command below.<\/p>\n<pre class=\"lang:default decode:true \">Restore-DbaDatabase -SqlInstance localhost -Path D:\\SQLBackup\\MSHOWTO -DestinationDataDirectory D:\\SQLDATA -withreplace<\/pre>\n<p>After running the command, the output below gives us the transaction details.<\/p>\n<figure style=\"width: 1261px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-7-1.png\" alt=\"\" width=\"1261\" height=\"349\" \/><figcaption class=\"wp-caption-text\">Picture-7<\/figcaption><\/figure>\n<p>As you can see, the MSHOWTO database has now been restored to D:\\SQLData. Let&#8217;s check the D:\\SQLData path.<\/p>\n<figure style=\"width: 678px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-8-1.png\" alt=\"\" width=\"678\" height=\"119\" \/><figcaption class=\"wp-caption-text\">Picture-8<\/figcaption><\/figure>\n<h3>How to restore to a different directory?<\/h3>\n<p>So far, when restoring, we have restored both data files and log files to the same directory.<\/p>\n<p>However, we know that the best method is to have data and log files on different disks.<\/p>\n<p>In our example, let&#8217;s perform the restoration operations on the following file paths. (I have only one disk available in the environment I work in, so I will process different file paths on the same disk.)<\/p>\n<p>Data: D:\\SQLData\\DataFile (The value to be given to the DestinationDataDirectory parameter)<\/p>\n<p>Log: D:\\SQLData\\LogFile (The value to be given to the DestinationLogDirectory parameter)<\/p>\n<p>Command:<\/p>\n<pre class=\"lang:default decode:true \">Restore-DbaDatabase -SqlInstance localhost -Path D:\\SqlBackup -DestinationDataDirectory D:\\SqlData\\DataFile \r\n-DestinationLogDirectory D:\\SqlData\\LogFile -withReplace<\/pre>\n<p>After running the command, it will give us the following output.<\/p>\n<figure style=\"width: 1454px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-9-1.png\" alt=\"\" width=\"1454\" height=\"361\" \/><figcaption class=\"wp-caption-text\">Picture-9<\/figcaption><\/figure>\n<p>Let&#8217;s check the file paths.<\/p>\n<figure style=\"width: 675px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-10-1.png\" alt=\"\" width=\"675\" height=\"119\" \/><figcaption class=\"wp-caption-text\">Picture-10<\/figcaption><\/figure>\n<figure style=\"width: 673px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-11-1.png\" alt=\"\" width=\"673\" height=\"118\" \/><figcaption class=\"wp-caption-text\">Picture-11<\/figcaption><\/figure>\n<h3>How to restore a new database of names?<\/h3>\n<p>In our previous example, we crushed an existing database with the Replace option and restored from backup.<\/p>\n<p>However, in most cases, we need to restore a new database with a different name instead of crushing the existing one.<\/p>\n<p>In this example, let&#8217;s restore the MSHOWTO database from the backup we have, from a new backup named MSHOWTO_Restore.<\/p>\n<p>Before performing the operation, we need the logical and physical name information of the current database, this information can be obtained using the sp_helpfile command.<\/p>\n<p>The output of the sp_helpfile command is as follows.<\/p>\n<figure style=\"width: 709px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-12-1.png\" alt=\"\" width=\"709\" height=\"60\" \/><figcaption class=\"wp-caption-text\">Picture-12<\/figcaption><\/figure>\n<p>We have specified a new database with the ReplaceDbNameInFile specified along with the DatabaseName parameter in the command below.<\/p>\n<pre class=\"lang:default decode:true \">Restore-DbaDatabase -SqlInstance localhost -Path D:\\SQLBackup\\MSHOWTO -DatabaseName MSHOWTO_Restore -\r\nReplaceDbNameInFile<\/pre>\n<p>The above command gives us the following output.<\/p>\n<figure style=\"width: 1134px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-13-1.png\" alt=\"\" width=\"1134\" height=\"365\" \/><figcaption class=\"wp-caption-text\">Picture-13<\/figcaption><\/figure>\n<p>Let&#8217;s run the sp_helpfile command for the MSHOWTO_Restore database.<\/p>\n<p>We can see that the physical file names have changed. Similar output is also available in the image above.<\/p>\n<figure style=\"width: 1059px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-14-1.png\" alt=\"\" width=\"1059\" height=\"68\" \/><figcaption class=\"wp-caption-text\">Picture-14<\/figcaption><\/figure>\n<p>To change the logical file names, the Rename-DbaDatabase command in the DBATools module can be used to change the logical file names after the restoration.<\/p>\n<p>This way, we can have a more readable restoration process.<\/p>\n<pre class=\"lang:default decode:true \">Rename-DbaDatabase -SQLInstance localhost -DatabaseName MSHOWTO_Restore -LogicalName \u201cMSHOWTO_Restore\u201d\r\n<\/pre>\n<figure style=\"width: 874px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-15-1.png\" alt=\"\" width=\"874\" height=\"222\" \/><figcaption class=\"wp-caption-text\">Picture-15<\/figcaption><\/figure>\n<p>When we check with sp_helpfile, we can see that the logical names have changed.<\/p>\n<figure style=\"width: 1098px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-16.png\" alt=\"\" width=\"1098\" height=\"64\" \/><figcaption class=\"wp-caption-text\">Picture-16<\/figcaption><\/figure>\n<p>As seen in the picture above, the logical name change has been achieved, but if we want to define naming in data and log types, we can use the &lt;DBN&gt;_&lt;FT&gt; format as in the command below.<\/p>\n<p>So for the DBN part, it will replace it with the database name and add the _FT suffix.<\/p>\n<pre class=\"lang:default decode:true \">Rename-DbaDatabase -SQLInstance localhost -Database MSHOWTO_Restore -LogicalName \u201c&lt;DBN&gt;_&lt;FT&gt;\u201d\r\n<\/pre>\n<p>When we check the sp_helpfile again after running the above command, we will see a result like the following.<\/p>\n<figure style=\"width: 1119px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-17.png\" alt=\"\" width=\"1119\" height=\"59\" \/><figcaption class=\"wp-caption-text\">Picture-17<\/figcaption><\/figure>\n<h3>How to perform a Restore operation in NoRecovery mode?<\/h3>\n<p>We previously learned how to take differential and Log backups using the DbaTools module.<\/p>\n<p>These backups we take are not backups that can be restored on their own, so after any backup is restored, they can be restored immediately if the database is in &#8220;NORECOVERY&#8221; or &#8220;STANDBY&#8221; state.<\/p>\n<p>We can use the NoRecovery parameter to fulfill this requirement using Dbatools.<\/p>\n<pre class=\"lang:default decode:true \">Restore-DbaDatabase -SQLInstance localhost -Path D:\\SqlBackup\\MSHOWTO -Database \u201cMSHOWTO_NORECOVERY\u201d -\r\nReplaceDbNameInFile  \u2013NoRecovery\r\n<\/pre>\n<p>The output of the command is as follows.<\/p>\n<figure style=\"width: 1302px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-18.png\" alt=\"\" width=\"1302\" height=\"370\" \/><figcaption class=\"wp-caption-text\">Picture-18<\/figcaption><\/figure>\n<p>Let&#8217;s check the accuracy of the transaction we made from SSMS.<\/p>\n<figure style=\"width: 355px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-19.png\" alt=\"\" width=\"355\" height=\"229\" \/><figcaption class=\"wp-caption-text\">Picture-19<\/figcaption><\/figure>\n<p>Differential or log backup can now be restored for this database (MSHOWTO_NORECOVERY).<\/p>\n<p>After completing these restoration processes, we can use the following command to make the database usable again.<\/p>\n<pre class=\"lang:default decode:true \">Restore-DbaDatabase -SQLInstance Localhost -DatabaseName MSHOWTO_NORECOVERY \u2013Recover\r\n<\/pre>\n<p>The output of the command is as follows.<\/p>\n<figure style=\"width: 775px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-20.png\" alt=\"\" width=\"775\" height=\"96\" \/><figcaption class=\"wp-caption-text\">Picture-20<\/figcaption><\/figure>\n<p>When we check from SSMS, we see that the MSHOWTO_NORECOVERY database is now accessible.<\/p>\n<figure style=\"width: 355px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.mshowto.org\/images\/articles\/2019\/06\/Resim-21.png\" alt=\"\" width=\"355\" height=\"191\" \/><figcaption class=\"wp-caption-text\">Picture-21<\/figcaption><\/figure>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_55352\" class=\"pvc_stats all  \" data-element-id=\"55352\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In our previous article, we learned how to take a database backup using Powershell&#8217;s dbatools module, and in today&#8217;s article, I will explain how to restore the backup we took using dbatools. First of all, let&#8217;s learn which commands include restore in DBATools. To do this, we must run the following command in the powershell &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_55352\" class=\"pvc_stats all  \" data-element-id=\"55352\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1414,"featured_media":55374,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-55352","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-mssql"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Restore SQL Server Database Using PowerShell - Database Tutorials<\/title>\n<meta name=\"description\" content=\"We learned how to take a database backup using Powershell&#039;s dbatools module, and in today&#039;s article, I will explain how to restore the backup we took using dbatools.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Restore SQL Server Database Using PowerShell - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"We learned how to take a database backup using Powershell&#039;s dbatools module, and in today&#039;s article, I will explain how to restore the backup we took using dbatools.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-13T13:07:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-13T13:09:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png\" \/>\n\t<meta property=\"og:image:width\" content=\"751\" \/>\n\t<meta property=\"og:image:height\" content=\"368\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"\u00c7a\u011flar \u00d6zen\u00e7\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u00c7a\u011flar \u00d6zen\u00e7\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/\"},\"author\":{\"name\":\"\u00c7a\u011flar \u00d6zen\u00e7\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/92baa6fd666fb707d903177fed07d6ab\"},\"headline\":\"How To Restore SQL Server Database Using PowerShell\",\"datePublished\":\"2023-11-13T13:07:03+00:00\",\"dateModified\":\"2023-11-13T13:09:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/\"},\"wordCount\":1048,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png\",\"articleSection\":[\"MSSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/\",\"name\":\"How To Restore SQL Server Database Using PowerShell - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png\",\"datePublished\":\"2023-11-13T13:07:03+00:00\",\"dateModified\":\"2023-11-13T13:09:29+00:00\",\"description\":\"We learned how to take a database backup using Powershell's dbatools module, and in today's article, I will explain how to restore the backup we took using dbatools.\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#primaryimage\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png\",\"width\":751,\"height\":368},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Restore SQL Server Database Using PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/92baa6fd666fb707d903177fed07d6ab\",\"name\":\"\u00c7a\u011flar \u00d6zen\u00e7\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/997658bc236de4f5a0f3f46e64535566e31ba96824c77c01165e863fc38fd1ba?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/997658bc236de4f5a0f3f46e64535566e31ba96824c77c01165e863fc38fd1ba?s=96&d=mm&r=g\",\"caption\":\"\u00c7a\u011flar \u00d6zen\u00e7\"},\"url\":\"https:\/\/dbtut.com\/index.php\/author\/caglarozenc\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Restore SQL Server Database Using PowerShell - Database Tutorials","description":"We learned how to take a database backup using Powershell's dbatools module, and in today's article, I will explain how to restore the backup we took using dbatools.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/","og_locale":"en_US","og_type":"article","og_title":"How To Restore SQL Server Database Using PowerShell - Database Tutorials","og_description":"We learned how to take a database backup using Powershell's dbatools module, and in today's article, I will explain how to restore the backup we took using dbatools.","og_url":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/","og_site_name":"Database Tutorials","article_published_time":"2023-11-13T13:07:03+00:00","article_modified_time":"2023-11-13T13:09:29+00:00","og_image":[{"width":751,"height":368,"url":"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png","type":"image\/png"}],"author":"\u00c7a\u011flar \u00d6zen\u00e7","twitter_card":"summary_large_image","twitter_misc":{"Written by":"\u00c7a\u011flar \u00d6zen\u00e7","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/"},"author":{"name":"\u00c7a\u011flar \u00d6zen\u00e7","@id":"https:\/\/dbtut.com\/#\/schema\/person\/92baa6fd666fb707d903177fed07d6ab"},"headline":"How To Restore SQL Server Database Using PowerShell","datePublished":"2023-11-13T13:07:03+00:00","dateModified":"2023-11-13T13:09:29+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/"},"wordCount":1048,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png","articleSection":["MSSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/","url":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/","name":"How To Restore SQL Server Database Using PowerShell - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#primaryimage"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png","datePublished":"2023-11-13T13:07:03+00:00","dateModified":"2023-11-13T13:09:29+00:00","description":"We learned how to take a database backup using Powershell's dbatools module, and in today's article, I will explain how to restore the backup we took using dbatools.","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#primaryimage","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2023\/11\/Ekran-goruntusu-2023-11-13-160506.png","width":751,"height":368},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2023\/11\/13\/how-to-restore-sql-server-database-using-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"How To Restore SQL Server Database Using PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/92baa6fd666fb707d903177fed07d6ab","name":"\u00c7a\u011flar \u00d6zen\u00e7","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/997658bc236de4f5a0f3f46e64535566e31ba96824c77c01165e863fc38fd1ba?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/997658bc236de4f5a0f3f46e64535566e31ba96824c77c01165e863fc38fd1ba?s=96&d=mm&r=g","caption":"\u00c7a\u011flar \u00d6zen\u00e7"},"url":"https:\/\/dbtut.com\/index.php\/author\/caglarozenc\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/55352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/1414"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=55352"}],"version-history":[{"count":3,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/55352\/revisions"}],"predecessor-version":[{"id":55377,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/55352\/revisions\/55377"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media\/55374"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=55352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=55352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=55352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}