🩹 [Patch]: Enrich the output from Resolve-DnsHost to match Windows' Resolve-DnsName #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch enriches the output from
Resolve-DnsHost
to provide detailed DNS record information similar to Windows'Resolve-DnsName
cmdlet.Changes Made
New
DnsRecord
ClassAdded a new
DnsRecord
class with properties that match the structure ofResolve-DnsName
output:Name
,Type
,TTL
,Section
,IPAddress
,Address
,QueryType
IP4Address
/IP6Address
(populated based on record type)CharacterSet
,DataLength
Enhanced
Resolve-DnsHost
FunctionUpdated the function to:
DnsRecord
objects instead of a singleDnsHost
objectBefore vs After
Before (simple output):
After (rich output matching Resolve-DnsName):
The output now provides the same rich DNS record information as Windows'
Resolve-DnsName
, including proper handling of both IPv4 (A records) and IPv6 (AAAA records) with appropriate metadata.Fixes #4.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
8.8.8.8.in-addr.arpa
pwsh -Command try { [System.Net.Dns]::GetHostEntry('8.8.8.8') | Format-List } catch { Write-Host 'Error:' $_.Exception.Message }
(dns block)google.com
pwsh -Command . ./src/classes/public/DnsHost.ps1; . ./src/functions/public/Resolve-DnsHost.ps1; Resolve-DnsHost -Name 'google.com'
(dns block)pwsh -Command . ./src/classes/public/DnsHost.ps1; . ./src/functions/public/Resolve-DnsHost.ps1; $result = Resolve-DnsHost -Name 'google.com'; $result | Format-List
(dns block)pwsh -Command . ./src/classes/public/DnsHost.ps1; . ./src/functions/public/Resolve-DnsHost.ps1; $result = Resolve-DnsHost -Name 'google.com'; Write-Host 'Result:'; $result
(dns block)nonexistent.invalid.domain.test
pwsh -Command . ./src/classes/public/DnsRecord.ps1; . ./src/functions/public/Resolve-DnsHost.ps1; Import-Module Pester -Force; Invoke-Pester tests/Dns.Tests.ps1 -Output Detailed
(dns block)pwsh -Command . ./src/classes/public/DnsRecord.ps1; . ./src/functions/public/Resolve-DnsHost.ps1; Import-Module Pester -Force; Invoke-Pester tests/Dns.Tests.ps1 -Output Normal
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.