title: PowerShell Scripts Using .NET SQLConnection Class Are Interfering With Each Other
body: <p>I run multiple instances of a single PowerShell script that monitors a shared folder for new JSON files and then uploads those JSON files to an Azure SQL database to be converted into tabular data. I run multiple instances of the script so I can have redundancy and more bandwidth to upload the files since there are often dozens of JSON files in the shared folder that need to be uploaded. </p>
  
  <p>My problem is that sometimes one instance of the script will start running the <code>ExecuteNonQuery()</code> method from the <code>System.Data.SqlClient.SqlCommand</code> class and it will just hang. This usually just causes that one instance of the script to hang, but sometimes it freezes up one or more of the other instances of the script that are running. Once I close the offending instance, everything else starts running normally again. </p>
  
  <p>Yesterday I also noticed that a completely unrelated PowerShell script that also uses the <code>System.Data.SqlClient.SqlCommand</code> class kicked off while the other script was hung, and it froze too until the first script window was closed. </p>
  
  <p>My question is, how do I investigate and resolve this issue? I assume PowerShell somehow shares resources across scripts and if one script locks up that resources then all other scripts are out of luck. Is there any way around that, or a programming best practice to use when that happens?</p>