Here’s a PowerShell script, by Microsoft’s Dave Browne, to install SQL Server Express Edition and restore a database from a command line. It’s intended to be used as part of an installation script for an application that needs a local SQL Express instance. But it also demonstrates several SQL Server and Powershell interop features like handling InfoMessages from the server, dealing with resultsets, embedding TSQL commands with Powershell Here Strings.


Anyway the script assumes that it is sitting in a folder next to the backup file and the SQL Express install media. You would supply the name of your database to restore and the instance name if you want something other than the default “SQLExpress”.

Read on at David Browne’s Web Log.

This may interest you:   Always_populate_raw_post_data setting in PHP 5.6 & Magento 2.0