I have a "SQL"
script that needs to be run through Windows Powershell
in order to create a database. The script already has the drop and create function in so no need to add a database name at the end of the command line. when trying to execute the command line I get an error that says
"Invoke-Sqlcmd : A network-related or instance-specific error occurred while establishing a connection to SQL Server
The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)
At line:1 char:14
+ invoke-sqlcmd <<<< -inputfile "c:\A.sql" -serverinstance "Louis_dev\MSSQLSERVER"
+ CategoryInfo : InvalidOperation: (:) [Invoke-Sqlcmd], SqlException
+ FullyQualifiedErrorId : SqlExectionError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand
Invoke-Sqlcmd :
At line:1 char:14
+ invoke-sqlcmd <<<< -inputfile "c:\A.sql" -serverinstance "Louis_dev\MSSQLSERVER"
+ CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], ParserException
+ FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand"
not sure if it is the invoke command and I have already followed the steps in this link How to execute .sql file using powershell? . Is there by any chance that there could be a workaround from this error. SQLSERVER
instance has been configured to LocalSystem
and not to Network instance