Sunday, June 14, 2015

Powershell Connection string to an instance of SQL Server 2012 on local computer

We are assuming a named instance 'RegencyPark' on a laptop machine named 'Hodentek8'. The Connection string used for connecting to this instance using PowerShell is in the string variable $ConnectionString:


Windows PowerShell ISE provides intellisense support and for the Connection provides the following drop-down:

You can use the following statements to connect to the instance and open the connection (Properties and Methods):

$Connection = New-Object System.Data.SQLClient.SQLConnection($ConnectionString)

The last statement when executed displays 'Open'

You can further looks at the properties of the connection string as shown here:
PS C:\Users\Jayaram>

PS C:\Users\Jayaram>  $Connection = New-Object System.Data.SQLClient.SQLConnection($ConnectionString)

PS C:\Users\Jayaram>  $Connection.Open()

PS C:\Users\Jayaram>  $Connection.State

PS C:\Users\Jayaram>  $Connection.Database

PS C:\Users\Jayaram>  $Connection.Credential

PS C:\Users\Jayaram>  $Connection.DataSource

PS C:\Users\Jayaram>  $Connection.ConnectionTimeout

Get the March 2018 Power BI update

The update is out and you can get it from here : You can also get it from Windows Store if you are running Windows 10. Well what is n...