Is it possible to use a connection string like:
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
?
At the time this question was asked, no. More recently, yes, Invoke-Sqlcmd
now supports a -ConnectionString
parameter that accepts a standard database connection string as a value.
Previously, you'd need to break out each of the parameters in your connection string and match them up with the parameters that Invoke-Sqlcmd
accepts.
If you had the flexibility and are stuck with a frozen legacy environment, you may wish to bodge Chad Miller's Invoke Sqlcmd2
and make it accept an ADO.NET connection string as one of its parameters:
https://gallery.technet.microsoft.com/scriptcenter/7985b7ef-ed89-4dfd-b02a-433cc4e30894
Actually, Yes.
As of this writing the invoke-sqlcmd
available in the SQLServer module includes a -connectionString
parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With