Closed jbalcorn closed 2 years ago
The message text of the terminating error thrown if the auth token used has expired is "[401] The session token is missing, invalid or expired.
"
$_.Exception.message -match "Run New-PASSession"
will never equate to true in this scenario.
$_.Exception.message -match "expired"
should work?
otherwise something similar to the below:
try{
Get-PASAccount
}
Catch [System.Exception] {
if($_.FullyQualifiedErrorId -eq "PASWS006E,Invoke-PASRestMethod"){"Token Expired"}else{throw $_}
}
Well, that was dumb. I was absolutely sure that I had tried this multiple times...and yet it appears that I had the right idea it was just a dumb mistake that prevented it from working.
No problems, happens to us all sometimes 😀
Describe the issue For a long running job, knowing if the PASSession is still valid. Get-PASSession doesn't tell you if the session is valid and calling anything with a invalid session causes an uncatchable error.
To Reproduce Steps to reproduce the behavior:
Expected behavior
Would allow us to recover from a timed out session
Screenshots & Console Output If applicable, add screenshots and/or console output to help explain your problem.
Code is actually as above
Your Environment Include relevant details about your environment