Author Posts

August 23, 2018 at 7:47 am

I am new to powershell and I have been doing some tutorials and when I get an error message I understand what the :line 23 meand but I am not sure what the :char value represents. I assume it is character in that line but I wanted to be sure. Can anyone offer insight on how I can use these values to better locate the problem in my code. I would appreciate any help on this I can get.

August 23, 2018 at 7:48 am

That is correct, it is the index of the character on that line.

August 23, 2018 at 9:26 am

Yes and yo can get all the details of the error from the $Error automatic variable.
$Error is an array, so the last error will be in $Error[0].

You can explore $Error[0], it will have lot of information about the error.
eg:-

$Error[0].InvocationInfo

August 24, 2018 at 3:42 am

Thanks for the info. In my troubleshooting of things I have found the line number to be helpful but the char value seems arbitrary and doesn't really point to the problem on that line, unless, of course I am not understanding how to use that value to find the issue.

Thanks for the info on the $Error[] array.