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.
My name is Jan. I am not a hacker, coder, developer, programmer or guru. I am merely a system administrator, doing my daily thing at Vevida in the Netherlands. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, WordPress, websites & optimization. Want to support me and donate? Use this link: https://paypal.me/jreilink.
Use -SearchBase with Get-ADComputer for faster results
ASP and ASP.NET connection string examples for Microsoft SQL Server and MySQL
MySQL Connector/ODBC C# test script
How to use SSL in PHP Data Objects (PDO) mysql
Fatal error: Uncaught Error:  operator not supported for strings – PHP 7.1
How to determine if a SQL Server backup is compressed?
How to detect ethernet network speed in Windows
List all MAC addresses of all Hyper-V Virtual Machines