In Powershell, I can use Enter-PSHostProcess
to debug specific programs. Since I’m doing a lot of debugging I thought I’d write a function to save me some time. The function:
function global:Debug-MyProgram {
Enter-PSHostProcess -Name "NameOfService"
Get-Runspace | Where-Object{$_.Debugger.InBreakpoint} | Debug-Runspace
}
The problem is that after running Enter-PSHostProcess
I no longer have access to the Debug-MyProgram
function because the PSHostProcess doesn’t inherit that function. The effect of this is that the Get-Runspace
line is never run.
Is there a way for me to keep using custom functions after entering a PS Host process?