How to fix Powershell Execution Timeout Expired with CommandTimeout

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"






Read More on Powerhsell and connecting to SQL Server 

Powershell - run script on all sql servers

Powershell for SQL SMO

SQL Server - SQL Server Restart with Powershell 

Author: Jack Vamvas (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

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.


Post a comment on How to fix Powershell Execution Timeout Expired with CommandTimeout | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer