Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 27, 2025

This patch enriches the output from Resolve-DnsHost to provide detailed DNS record information similar to Windows' Resolve-DnsName cmdlet.

Changes Made

New DnsRecord Class

Added a new DnsRecord class with properties that match the structure of Resolve-DnsName output:

  • Name, Type, TTL, Section, IPAddress, Address, QueryType
  • IP4Address/IP6Address (populated based on record type)
  • CharacterSet, DataLength

Enhanced Resolve-DnsHost Function

Updated the function to:

  • Return an array of DnsRecord objects instead of a single DnsHost object
  • Create separate records for each resolved IP address
  • Automatically identify A vs AAAA record types based on address family
  • Include rich DNS metadata for each record

Before vs After

Before (simple output):

Name: hostname
Alias: alias  
AddressList: [array of IPs]

After (rich output matching Resolve-DnsName):

Name         : localhost
Type         : A
TTL          : 60
Section      : Answer
IPAddress    : 127.0.0.1
Address      : 127.0.0.1
QueryType    : A
IP4Address   : 127.0.0.1
IP6Address   : 
CharacterSet : Unicode
DataLength   : 4

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
    • Triggering command: pwsh -Command try { [System.Net.Dns]::GetHostEntry('8.8.8.8') | Format-List } catch { Write-Host 'Error:' $_.Exception.Message } (dns block)
  • google.com
    • Triggering command: pwsh -Command . ./src/classes/public/DnsHost.ps1; . ./src/functions/public/Resolve-DnsHost.ps1; Resolve-DnsHost -Name 'google.com' (dns block)
    • Triggering command: pwsh -Command . ./src/classes/public/DnsHost.ps1; . ./src/functions/public/Resolve-DnsHost.ps1; $result = Resolve-DnsHost -Name 'google.com'; $result | Format-List (dns block)
    • Triggering command: 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
    • Triggering command: 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)
    • Triggering command: 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.

Copy link
Author

Copilot AI commented Aug 27, 2025

@MariusStorhaug 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] 🩹 [Patch]: Enrich the output from Resolve-DnsHost, in line with what we get from Windows' Resolve-DnsName 🩹 [Patch]: Enrich the output from Resolve-DnsHost to match Windows' Resolve-DnsName Aug 27, 2025
@Copilot Copilot AI requested a review from MariusStorhaug August 27, 2025 11:02
Copilot finished work on behalf of MariusStorhaug August 27, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🩹 [Patch]: Enrich the output from Resolve-DnsHost, in line with what we get from Windows' Resolve-DnsName
2 participants