Failed to connect to server...

Jul 21, 2010 at 5:29 PM

I have a (Powersehll) script that goes thru each SQL server and issues a SQL SELECT statement using Get-SQLData cmdlet. For some servers it worked, but for others it returned the following error:

Exception calling "Connect" with "0" argument(s): "Failed to connect to server MyServer."

But when I run the same command for only the server that failed, it ran successfully. So, I was wondering is it because the connection time was not enough that caused the connection to fail ? If this is true, is this error coming from Get-SQLData ?  Is there a way to set the connection time ? or should I issue a Start-Sleep after the Get-SQLData to avoid connection timeout ?

Please help. Thanks in advance.