SQLServerPSModule
SQLServerPSModule copied to clipboard
Using Invoke-SqlCmd in ForEach-Object -Parallel loop - not threadsafe?
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