given the script.
$foo = @("bar")
try {
$foo | ForEach-Object {
Join-Path $null $null
}
} catch {
$_.InvocationInfo.Line
}
will print
$foo | ForEach-Object {
but I would like
Join-Path $null $null
How can I get where the exception was actually raised?
This will get you the actual line:
and exception message:
and line number:
and offset (column):
So you could make a helpful little message: