I'm not sure if this is even possible, as everything I've found online seems to suggest it isn't. So, asking here is my last hope.
Is it possible to run code in a PSHostProcess in a similar way to how one can with Invoke-Command using the -Session or -ComputerName parameters? Of course, there’s Enter-PSHostProcess, but I’d like to do this in the middle of a script, not manually on the command line.
The reason I want to do this is so I can write a helper script that iterates through all the currently running pwsh processes. For each one, it would use Get-Runspace to find any runspaces currently in an InBreakpoint state, and then use Debug-Runspace to start the debugger.
The helper script could also check if multiple runspaces are in the InBreakpoint state and prompt for the correct one to debug.
Thanks in advance.