From c98775ce3cfe9123a7dda27861295fdbe50e76d9 Mon Sep 17 00:00:00 2001 From: Colin Cogle Date: Wed, 6 Dec 2023 21:38:39 -0500 Subject: [PATCH] Indent Test-MailPolicy's IP version checks. This commit adds a tiny new feature. When `Test-IPVersions` is run from `Test-MailPolicy`, the output lines will be indented for clarity. This makes use of a hidden parameter to control indentation. When `Test-IPVersions` is invoked directly, the output will not be modified from how it appeared in previous versions. --- CHANGELOG.md | 1 + MailPolicyExplainer.psd1 | 5 +++-- src/MailPolicyExplainer.psm1 | 20 ++++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa9ee83..2f2a282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # MailPolicyExplainer Change Log ## Version 1.3.1 (Wednesday, December 9, 2023) +- **NEW** The IP version checks are now displayed with an indentation when run as a part of `Test-MailPolicy`. - **FIX** The DMARC `fo` token is now parsed correctly when multiple values are present. - **FIX** The DMARC `rf` token is now parsed correctly. diff --git a/MailPolicyExplainer.psd1 b/MailPolicyExplainer.psd1 index 6011db1..e7a25db 100644 --- a/MailPolicyExplainer.psd1 +++ b/MailPolicyExplainer.psd1 @@ -167,9 +167,10 @@ PrivateData = @{ IconUri = 'https://raw.githubusercontent.com/rhymeswithmogul/MailPolicyExplainer/main/icon/PSGallery.png' # ReleaseNotes of this module - ReleaseNotes = 'This release fixes many bugs: + ReleaseNotes = 'This release fixes many bugs and offers minor enhancements: - The DMARC `fo` token is now parsed correctly when multiple values are present. -- The DMARC `rf` token is now parsed correctly.' +- The DMARC `rf` token is now parsed correctly. +- IP version checks are now indented when run from `Test-MailPolicy`.' } # End of PSData hashtable diff --git a/src/MailPolicyExplainer.psm1 b/src/MailPolicyExplainer.psm1 index a98d8ac..356a8a8 100644 --- a/src/MailPolicyExplainer.psm1 +++ b/src/MailPolicyExplainer.psm1 @@ -169,21 +169,29 @@ Function Test-IPVersions Param( [Parameter(Mandatory, Position=0)] [ValidateNotNullOrEmpty()] - [String] $HostName + [String] $HostName, + + [Parameter(DontShow)] + [Switch] $IndentOutput ) + $Indent = '' + If ($IndentOutput) { + $Indent = '├──' + } + If (Test-IPv4Address $HostName) { - Write-GoodNews "IP: The server $HostName has an IPv4 address." + Write-GoodNews "${Indent}IP: The server $HostName has an IPv4 address." } Else { - Write-BadPractice "IP: The server $HostName has no IPv4 addresses. IPv4-only clients cannot reach this server." + Write-BadPractice "${Indent}IP: The server $HostName has no IPv4 addresses. IPv4-only clients cannot reach this server." } If (Test-IPv6Address $HostName) { - Write-GoodNews "IP: The server $HostName has an IPv6 address." + Write-GoodNews "${Indent}IP: The server $HostName has an IPv6 address." } Else { - Write-BadPractice "IP: The server $HostName has no IPv6 addresses. IPv6-only clients cannot reach this server!" + Write-BadPractice "${Indent}IP: The server $HostName has no IPv6 addresses. IPv6-only clients cannot reach this server!" } } @@ -691,7 +699,7 @@ Function Test-MXRecord Else { Write-GoodNews "MX: The server $($_.Server) can receive mail for this domain (at priority $($_.Preference))." } - Test-IPVersions ($_.Server) + Test-IPVersions ($_.Server) -Indent } }