From c97842f2685b987230e68fd7057f0741868c1433 Mon Sep 17 00:00:00 2001 From: Spam Me <295566+styx-tdo@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:28:35 +0200 Subject: [PATCH] Fix variable name certfileMY Add check for friendly name, use Subject if not present --- scripts/Win_IIS_Check_SSL_Certs.ps1 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/Win_IIS_Check_SSL_Certs.ps1 b/scripts/Win_IIS_Check_SSL_Certs.ps1 index e97b5bc..08146f1 100644 --- a/scripts/Win_IIS_Check_SSL_Certs.ps1 +++ b/scripts/Win_IIS_Check_SSL_Certs.ps1 @@ -10,9 +10,10 @@ .INSTRUCTIONS Add this as a script check to your Windows Server that has IIS installed. .NOTES - Version: 1.0 + Version: 1.1 Author: ebdavison (nalantha on discord) Creation Date: 2022-08-08 + Updated: 2024-07-25 styx-tdo #> param @@ -60,13 +61,21 @@ $CertState = foreach ($bind in $bindingslist) { if ($certFileWH.NotAfter) { if ($certFileWH.NotAfter -lt $Days) { - "$($bindsite) = $($certfileWH.FriendlyName) / $($certfileWH.thumbprint) will expire on $($certfileWH.NotAfter)" + if (certfileWH.FriendlyName) { + "$($bindsite) = $($certfileWH.FriendlyName) / $($certfileWH.thumbprint) will expire on $($certfileWH.NotAfter)" + }else{ + "$($bindsite) = $($certfileWH.Subject) / $($certfileWH.thumbprint) will expire on $($certfileWH.NotAfter)" + } } } if ($certFileMY.NotAfter) { if ($certFileMY.NotAfter -lt $Days) { - "$($bindsite) = $($certfileMY.FriendlyName) / $($certfileMY.thumbprint) will expire on $($certfileWMY.NotAfter)" + if (certfileMY.FriendlyName) { + "$($bindsite) = $($certfileMY.FriendlyName) / $($certfileMY.thumbprint) will expire on $($certfileMY.NotAfter)" + }else{ + "$($bindsite) = $($certfileMY.Subject) / $($certfileMY.thumbprint) will expire on $($certfileMY.NotAfter)" + } } } } @@ -78,4 +87,4 @@ if (!$certState){ } else { Write-Output $CertState exit 1 -} \ No newline at end of file +}