Sometimes I have to troubleshoot connection issues... or even query performance issues... for various applications. It can be very valuable to mimic the connection settings including MARS and connection pooling.
Here's how to do that - code snippets at the end of the post.
In the capture below I construct my desired connection string - in this case with MARS enabled and connection pooling disabled. I bring back one row/one column with a SQL statement just to confirm it worked :-)
Here I specifically enabled MARS because its something I'm looking into right now.
Can we see the MARS connection from the database server side? Yep. Code snippet for this also at the end of the blog post.
OK. Let's be nice and call Dispose. Oops - typo. Try again.
OK. Since Connection Pooling was disabled for this connection, it should disappear right away. And it is really gone. (It can take 4 to 8 minutes for an idle pool connection to disappear by default.)
The PowerShell code...
The SQL query to see the PowerShell MARS session...