So I’ve been writing a lot of Powershell scripts lately. Particularly with respect to SharePoint config and SQL Backup & Restores.
Running some of these restores has been problematic and I’d quote often see this unhelpful error.
Exception calling "SqlRestore" with "1" argument(s): "Restore failed for Server 'demo2010a'. "
At C:\Scripts\RestoreDB.ps1:104 char:23
+ $smoRestore.SqlRestore <<<< ($server)
So what really went wrong here?
Enter this command:
Basically the errors that have occurred are put into a stack and this command allows you to reference then array style where the 0th element is the most recent error and format-list –force outputs a full stack trace of the exception that occurred.
In my case I didn’t have exclusive access to the database which is required for a restore, so I was able to add this line to me restore script:
Hope you find this useful
That’s awesome info and helped me. I had the same issue and was able to confirm by looking at the error stack. Thanks again!