❔ Catching more detailed errors for PowerShell in C# web application (.Net6)
I have a snippet of code here that does catch generic errors fine but I am having a hard time troubleshooting without more details about the error.
The following helps catch the general error. I am wondering if anyone knows how to improve it so it can catch the full error:
...
note:
-ps is type Powershell
- errorMsg is type string
Thanks in advance!
The following helps catch the general error. I am wondering if anyone knows how to improve it so it can catch the full error:
...
note:
-ps is type Powershell
- errorMsg is type string
ps.Streams.Error.DataAdded += (object sender, DataAddedEventArgs e) =>
{
errorMsg = ((PSDataCollection<ErrorRecord>)sender)[e.Index].ToString();
};Thanks in advance!
