So ... remember when I said that we're not introducing any additional functions? I lied. There's one. However, it's very useful ... I swear!
I still believe that PSWriteLog shouldn't be required to just run the script. So, here's how you can use Resolve-Error:
Resolve-Error
try { # Do something that throws an error ... } catch { $resolvedError = if (Get-Command 'Resolve-Error' -ErrorAction 'Ignore') { Resolve-Error } else { $_.Exception.Message } Write-Error ('Failed to do a thing. {0}' -f $resolvedError) }
There was an error while loading. Please reload this page.