-
Notifications
You must be signed in to change notification settings - Fork 0
Functions
Raymond Piller edited this page Jan 12, 2023
·
1 revision
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
:
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)
}