Hello everybody,
I play around with PowerShell for a few years, and today I receive a sum-up documentation from TradePub, that presents the CmdLet Get-SqlDatabase
I did not even imagine it was possible to connect to a database with PowerShell, so I try and connect to this :
Product : Microsoft SQL Server 2014
Instance : SQLEXPRESS
Instance ID : MSSQL12.SQLEXPRESS
Feature : Services Moteur de base de données
Language : 1033
Edition : Express Edition
Version : 12.0.2269.0
Clustered : Non
Configured : Oui
I don’t use that cmdlet but the error message is pretty clear: the ServerInstance name you fed it cannot be found. Based on your prompt (PS SQLSERVER) it seems that you are already on the SQL server.
Have you tried running Get-SqlDatabase by itself with no arguments?
Down the page I see a thread about PowerShell 2.0 and SqlServer 2005.
Copying the code from there I obtain $conn.State = Open, which is a good beginning.
It does not use Get-SqlDatabase.
For the connection string I have to pay attention to give TrustServerCertificate in one word, whereas in SSMS it is written in three words.
I realize that with Get-SqlDatabase I gave no connection string.