Invoke-SqlCmd Failing

A really annoying problem I hit recently with a some Azure Runbooks was the following message occuring: Invoke-Sqlcmd : The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support Services. After doing some digging, I found out that Invoke-SqlCmd isn’t thread safe, so other runbooks running on that Azure Automation account, could interfere with each other....

July 16, 2020 · 2 min · matt40k