Is it possible to pass the standard ado connection string to Invoke-SqlCmd

Is it possible to use a connection string, for example:

Data Source=[server];Initial Catalog=[database];Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False

or

"Provider=SQLOLEDB.1;Persist Security Info=True;Initial Catalog=[database];Data Source=[server];uid=[username];pwd=[password];Pooling=true;Min Pool Size=10;Max Pool Size=500;Incr Pool Size=5;MultipleActiveResultSets=true;"

with Invoke-Sqlcmd?

+4
source share
2 answers

In short, no.

You will need to wrest each of the parameters in the connection string and match them with the parameters that it Invoke-Sqlcmdaccepts.

If you have the flexibility, you might want to host Chad Miller Invoke Sqlcmd2and force it to accept the ADO.NET connection string as one of its parameters:

https://gallery.technet.microsoft.com/scriptcenter/7985b7ef-ed89-4dfd-b02a-433cc4e30894

+1
source

Actually, yes.

invoke-sqlcmd, SQLServer, -connectionString.

+5

Source: https://habr.com/ru/post/1606729/


All Articles