From 3aeb429642a6d97634f5633b465eb47f75b46058 Mon Sep 17 00:00:00 2001 From: David Paulson Date: Fri, 5 Jan 2024 12:21:22 -0600 Subject: [PATCH] Address bug with HSTS detection with no ; in value --- .../IISInformation/Get-IISWebSite.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Diagnostics/HealthChecker/DataCollection/ExchangeInformation/IISInformation/Get-IISWebSite.ps1 b/Diagnostics/HealthChecker/DataCollection/ExchangeInformation/IISInformation/Get-IISWebSite.ps1 index 6789e06794..48595c5edd 100644 --- a/Diagnostics/HealthChecker/DataCollection/ExchangeInformation/IISInformation/Get-IISWebSite.ps1 +++ b/Diagnostics/HealthChecker/DataCollection/ExchangeInformation/IISInformation/Get-IISWebSite.ps1 @@ -101,9 +101,13 @@ function Get-IISWebSite { # add 8 to find the start index after 'max-age=' $maxAgeIndex = $maxAgeIndex + 8 - # subtract maxAgeIndex to get the length that we need to find the substring - $maxAgeValueIndex = $maxAgeValueIndex - $maxAgeIndex - $customHeaderHstsObj.'max-age' = $customHeaderHsts.Substring($maxAgeIndex, $maxAgeValueIndex) + if ($maxAgeValueIndex -ne -1) { + # subtract maxAgeIndex to get the length that we need to find the substring + $maxAgeValueIndex = $maxAgeValueIndex - $maxAgeIndex + $customHeaderHstsObj.'max-age' = $customHeaderHsts.Substring($maxAgeIndex, $maxAgeValueIndex) + } else { + $customHeaderHstsObj.'max-age' = $customHeaderHsts.Substring($maxAgeIndex) + } } else { Write-Verbose "max-age directive not found" }