26 July,2019 by Jack Vamvas
Question: I'm getting this Execution timeout error when executing a Powershell script using the $sql.ExecuteReader() method. How can I fix this issue?
Exception calling "ExecuteReader" with "0" argument(s): "Execution Timeout Expired. The timeout period elapsed prior
to completion of the operation or the server is not responding."
Answer: To overcome this issue - use the CommandTimeout parameter and set to a value of 0. This will make it infinite.
So it would be something like :
$cn = new-object System.Data.SqlClient.SqlConnection "server=myInstance;database=master;Integrated Security=sspi"
$cn.Open()
$cn.CreateCommand()
$sql.CommandText
$sql.CommandTimeout=0
$sql.CommandTimeout=0
$sql.ExecuteReader()
Read More on Powerhsell and connecting to SQL Server
Powershell - run script on all sql servers
SQL Server - SQL Server Restart with Powershell
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |