Some background:
- SharePoint+PowerShell is (Usually) a Perfect Match by Zach Rosenfield [MSFT]
- SharePoint+PowerShell Leak Workarounds by me
- SO: Could you explain STA and MTA?
In short, standard SharePoint guidance is that COM-backed objects like SPSite
and SPWeb
should not be used by different threads. This stands in conflict with PowerShell's use of MTA mode by default, verified in the Leak Workarounds post referenced above. One suggested workaround was to try PowerShell 2.0's -STA flag, which seems like it should solve the problem; however, in the comments on his post Zach suggests STA mode is not enough.
This pushes to the edge of my COM knowledge, so I'm hoping someone can help me understand...
- Should STA mode be sufficient to keep object access limited to a single thread across PowerShell pipelines?
- If not, why?