Fix issue in Verify-Link.ps1 after PS 7.4 update (#5314)

https://learn.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-74?view=powershell-7.4
- Add AllowInsecureRedirect switch to Web cmdlets (#18546)

That new option cause a new exception type that exposed
a bug where we assumed if InnerException property existed
that it was not null. This fix verifies that the property
is not null.

Co-authored-by: Wes Haggard <Wes.Haggard@microsoft.com>
This commit is contained in:
Azure SDK Bot 2024-02-02 11:27:55 -08:00 committed by GitHub
parent 46fcbbad52
commit 02882f9141
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -260,7 +260,7 @@ function CheckLink ([System.Uri]$linkUri, $allowRetry=$true)
$innerExceptionPresent = $_.Exception.psobject.Properties.name -contains "InnerException"
$errorCodePresent = $false
if ($innerExceptionPresent) {
if ($innerExceptionPresent -and $_.Exception.InnerException) {
$errorCodePresent = $_.Exception.InnerException.psobject.Properties.name -contains "ErrorCode"
}