Feature Request: Debug Capability for PowerShell Connector
Bob Bradley 4 years ago in PowerShell connector • updated by Adrian Corston 3 years ago • 3
Presently debugging a PowerShell connector script requires extensive use of logging.
While the above is still going to be necessary, the ability to attach a PowerShell ISE session to a PowerShell process to allow step-throughs and breakpoints is highly desirable.
# The following approach allows you to debug a PowerShell connector or adapter transform in IdB # See the following for background: # - https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/wait-debugger?view=powershell-6 # - https://stackoverflow.com/questions/42731150/how-to-pause-a-powershell-script-until-a-debugger-attaches # Prerequisite: PowerShell v5, IdB 5.*, PS connector or adapter transform # 1. Edit the PowerShell code and set a pause in your PowerShell code - long enough to intercept the process and enter debug mode: # you can use wait-debugger, but for now Matt showed me by using start-sleep instead #Wait-Debugger -Timeout 10 Start-Sleep 30 # 2. Find the process ID Get-Runspace # 3. Attach the ISE Enter-PSHostProcess -Name Unify.Service.Connect # 4. Debug the process Debug-Runspace -Id xx
Customer support service by UserEcho
Thanks for the suggestion. We'll investigate - there seems to potentially be a way to debug a script but may not involve the ISE.
Additional requirements - you must:
One way to do this is to log in as the UNIFYBroker service account in order to make the connection. Since the UNIFYBroker user is not normally granted remote login access this will need to be temporarily granted while debugging is taking place.
An alternative way to achieve this is via the following PowerShell (courtesy Matt Davis):
Further clarifications regarding using the commands listed by Bob above: