The PowerShell Scripting and Toolmaking Book
The PowerShell Scripting and Toolmaking Book
The PowerShell Scripting and Toolmaking Book
Don Jones
Windows PowerShell
Scripting and Toolmaking
Don Jones
Copyright ©2011 by Don Jones
http://ConcentratedTech.com
for Companion Materials, visit
http://MoreLunches.com
eBook Edition
ISBN 978-1-105-08285-6
After installing, go to PowerShell and verify the instance name by looking at the list of installed services:
Verifying the SQL Server Express Instance Name
• PS C:\Users\Administrator> get-service -name *sql*
•
• Status Name DisplayName
• ------ ---- -----------
• Stopped MSSQL$SQLEXPRESS SQL Server (SQLEXPRESS)
• Stopped MSSQLServerADHe... SQL Active Directory Helper Service
• Stopped SQLAgent$SQLEXP... SQL Server Agent (SQLEXPRESS)
• Stopped SQLBrowser SQL Server Browser
• Running SQLWriter SQL Server VSS Writer
Those services with (SQLEXPRESS) in the DisplayName are what I’m after. Notice that the key service here,
MSSQL$SQLEXPRESS, is stopped: That will need to be started in order for SQL Server to actually work. That’s the only
service that needs to be running for basic functionality.
• PS C:\Users\Administrator> start-service 'mssql$sqlexpress'
Now, we need to make a database to play with. On your Start Menu, locate SQL Server Management Studio and open it. If you
installed SQL Server using the defaults, you should be able to connect like this:
To keep this easy, immediately click the New Query button in the toolbar. I’ll give you a SQL query that will create a new
database and set up a new table within it.
Listing 9-1: Creating a Database
• CREATE DATABASE [Inventory] ON PRIMARY