Powershell SqlConnection Connection Timeout not honored in Powershell 7.x #19832
IanElsinga
started this conversation in
General
Replies: 1 comment 1 reply
-
$sqlConn = New-Object System.Data.SqlClient.SqlConnection("Data Source=DataSource;Initial Catalog=DataCatalog;Integrated Security=False;Connection Timeout=10;User ID=user;Password=pwd;") my share powershell sqlclient script : no timeout set on my script, |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I have spent much time looking for information on this and have found nothing. If this is not the right place to discuss this, could someone direct me to the correct place?
With Powershell 7.x, when using the SqlServer powershell module, or using the SMO SqlConnection object directly, the ConnectionTimeout parameter is not honored (either with Invoke-SqlCmd ConnectionTimeout parameter or with "Connection Timeout=x" in the connection string). Specifying anything below 15s results in a 15s timeout - which I assume is the default.
But when powershell 5.1 is used, the Connection Timeout parameter IS honored, and it times out precisely according to the value of the parameter.
Is this a bug? Is there a workaround? Many thanks for any information.
Beta Was this translation helpful? Give feedback.
All reactions