Open jplee75 opened 11 months ago
I know I posted this over the end of the year - is there more information I could provide to be helpful or possible to get an answer if Invoke-SqlCmd should be safe or not to use with For-Each Object -Parallel ?
Hi @jplee75 - I believe you are correct and this is a fairly old issue (it predates having this repo where we collect the issues).
For now and until I can take a look and fix it, I would recomment to stay away from it.
I'm able to reproduce the issue with version 22.2.0 of the SQLServer module on PowerShell version 7.4.2 and Microsoft Windows 10.0.19045.
It appears that Invoke-SqlCmd is not threadsafe - is this correct? Can it be made to be so?
Got this error while executing in a ForEach-Object -Parallel type loop
Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
[error]PowerShell exited with code '1'.
Version Info Name Value
PSVersion 7.4.0 PSEdition Core GitCommitId 7.4.0 OS Ubuntu 22.04.3 LTS Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
Name : SqlServer Path : /home/vsts/.local/share/powershell/Modules/SqlServer/22.1.1 /SqlServer.psd1 Version : 22.1.1