I have several PowerShell hosts in C #, from where I run the PowerShell script code. The code is below from the host in Add0In for Visual Studio. The problem is that if an error occurs in the PowerShell script code that does not know the file number and file line of the PowerShell script where the error occurred.
My hosting code looks like this:
public Exception Execute(string scriptcode, Hashtable variables) { Runspace runspace = null; Pipeline pipeline = null; PipelineStateInfo info = null; try {
At first I had my own script in the script code variable, now I will first write the code in a temporary .ps1 file so that I can report linenumbers in this file. But I canβt find how to execute the code in the file so that I can get the file name and line numbers in case of errors.
Any ideas?
source share