Skip to content

Commit

Permalink
Indent Test-MailPolicy's IP version checks.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rhymeswithmogul committed Dec 7, 2023
1 parent 74266f2 commit c98775c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
5 changes: 3 additions & 2 deletions MailPolicyExplainer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 14 additions & 6 deletions src/MailPolicyExplainer.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
}
}

Expand Down Expand Up @@ -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
}
}

Expand Down

0 comments on commit c98775c

Please sign in to comment.