Timeout error running invoke-SqlCmd

  • (I don't know where else to post this as there doesn't seem to be a category for people scripting sql in Powershell)

    I am trying to run a script in Powershell to backup a database but everytime I attempt it, I get the following timeout error:

    Invoke-Sqlcmd : Timeout expired. The timeout period elapsed prior to completio

    n of the operation or the server is not responding.

    The backup or restore was aborted.

    At line:1 char:14

    + Invoke-SqlCmd <<<< -ServerInstance "localhost" -Database "dbname" -Query "BA

    CKUP DATABASE [dbname] TO DISK='..file path'"

    Here is the command I am using:

    PS C:\testnewclient> Invoke-SqlCmd -ServerInstance "localhost" -Database "dbname

    " -Query "BACKUP DATABASE [dbname] TO DISK=file path"

    I am able to run the same backup command fine in sqlcmd in the DOS prompt and I have increased the timeout on the SQL Server using "sp_configure 'remote login timeout', 60

    go

    reconfigure with override

    go "

    Any suggestions?

  • i am having the same problem when attaching database, did u figured it out..

  • have you tried to add -QueryTimeout

    when using invoke-sqlcmd?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply