Can I get detailed exception stacktrace in PowerShell? – Stack Overflow

There is a function up on the PowerShell Team blog called Resolve-Error which will get you all kinds of detailsNote that $error is an array of all the errors you have encountered in your PSSession. This function will give you details on the last error you encountered.

Source: Can I get detailed exception stacktrace in PowerShell? – Stack Overflow

Powershell Generic Invoke-RestMethod / WebRequest error handler

From: https://stackoverflow.com/questions/39319680/onelogin-rest-api-with-powershells-invoke-restmethod

Then, wrap all of your Invoke-RestMethod calls in a try Catch block like this.

Now when you run into an error, you can see the actual message, like this