I have powershell script that add registration to event, but when the event is jump i'm getting the following error every time the event is jump: "no Runspace available to run scripts in this thread" I'm using PS v2, what can i do? Can you provide some code? Thanks
It sounds like you're trying to run script on a non-powershell thread, probably via an async callback. This is not a supported scenario. The trick is to "bridge" to callback to the eventing infrastructure, where scriptblocks haev a default runspace. Take a look at what I wrote here:
https://web.archive.org/web/20190222052659/http://www.nivot.org/blog/post/2009/10/09/PowerShell20AsynchronousCallbacksFromNET
It shows you how to work with async threads in powershell and run script in response to callbacks.
-Oisin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With