Skip to content

feat: add Add/Remove/Get-PiHoleDnsRecord - #144

Merged
mikemadeja merged 2 commits into
developfrom
feature/dns-record-management
Oct 15, 2026
Merged

mikemadeja merged 2 commits into
developfrom
feature/dns-record-management

Conversation

@mikemadeja

@mikemadeja mikemadeja commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds Add-PiHoleDnsRecord / Remove-PiHoleDnsRecord / Get-PiHoleDnsRecord as DNS-specific convenience wrappers for managing Pi-hole's local DNS records
  • This capability already existed generically via Add-PiHoleConfigArrayItem/Remove-PiHoleConfigArrayItem/Get-PiHoleConfig on dns/hosts and dns/cnameRecords - these just make it discoverable with typed, DNS-specific parameters instead of requiring callers to know Pi-hole's raw value format:
    Add-PiHoleDnsRecord -PiHoleServer $Server -Password $Password -Type A -Hostname "test.local" -IPv4Address "192.168.1.1"
    Add-PiHoleDnsRecord -PiHoleServer $Server -Password $Password -Type AAAA -Hostname "test.local" -IPv6Address "::1"
    Add-PiHoleDnsRecord -PiHoleServer $Server -Password $Password -Type CNAME -Hostname "alias.local" -Target "test.local" -Ttl 300
    
    Get-PiHoleDnsRecord -PiHoleServer $Server -Password $Password -Hostname "test.local" |
        Remove-PiHoleDnsRecord -PiHoleServer $Server -Password $Password
  • Add/Remove are thin wrappers that call the existing config-array functions internally rather than duplicating their auth/HTTP/error-handling logic. Get parses .Dns.Hosts/.Dns.CnameRecords into the same typed object shape (Type/Hostname/IPv4Address/IPv6Address/Target/Ttl), filterable by -Type/-Hostname
  • -IPv4Address/-IPv6Address are validated against the real .NET address family (so passing an IPv6 address to -IPv4Address or vice versa fails fast with a clear error, before any network call)
  • Remove-PiHoleDnsRecord implements its own -WhatIf/-Confirm via ShouldProcess, passing -Confirm:$false through to the inner call to avoid double-prompting
  • Remove-PiHoleDnsRecord accepts Get-PiHoleDnsRecord's output via ValueFromPipelineByPropertyName, including removing several matched records in one pipeline call - the first use of pipeline input anywhere in this module

Test plan

  • Manually created and removed one of each record type (A, AAAA, CNAME-with-TTL) against a live server, confirmed each via Get-PiHoleConfig/Get-PiHoleDnsRecord, confirmed clean removal
  • Manually verified the full Get-PiHoleDnsRecord | Remove-PiHoleDnsRecord pipeline, including removing multiple records (AAAA + CNAME) in one pipeline call
  • Integration tests pass against a live server (25/25 in the DnsControl folder, including the 4 pre-existing Set-PiHoleDnsBlocking/Get-PiHoleDnsBlockingStatus tests - no regressions): create/verify for all 3 types, filtering by -Type/-Hostname, RawOutput, the pipeline chain (single and multi-record), error paths (missing required param per type, invalid IPv4 format), -WhatIf performs no request, bad password
  • PSScriptAnalyzer clean
  • Full non-integration unit suite passes (18/18), including the module-export-integrity test confirming all three new functions are correctly exported
  • README.md / docs/EXAMPLES.md / manifest FunctionsToExport all regenerated

🤖 Generated with Claude Code

mikemadeja and others added 2 commits October 12, 2026 17:47
Adds DNS-specific convenience wrappers for managing Pi-hole's local
DNS records (A/AAAA host entries and CNAME records), which were
already reachable generically via Add-PiHoleConfigArrayItem /
Remove-PiHoleConfigArrayItem on dns/hosts and dns/cnameRecords - these
just make that discoverable with typed, DNS-specific parameters
(-Type A/AAAA/CNAME, -IPv4Address, -IPv6Address, -Target, -Ttl)
instead of requiring callers to know Pi-hole's raw value format
("<ip> <hostname>" or "<alias>,<target>[,<ttl>]").

Both are thin wrappers that call the existing config-array functions
internally rather than duplicating their auth/HTTP logic.
Remove-PiHoleDnsRecord implements its own ShouldProcess and passes
-Confirm:$false through to the inner call to avoid double-prompting.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds Get-PiHoleDnsRecord, completing the Get/Add/Remove set for local
DNS record management. Parses Pi-hole's raw dns.hosts/dns.cnameRecords
config arrays into the same typed object shape Add-/Remove-PiHoleDnsRecord
already use (Type/Hostname/IPv4Address/IPv6Address/Target/Ttl), with
optional -Type/-Hostname filtering.

Remove-PiHoleDnsRecord now accepts that same shape via
ValueFromPipelineByPropertyName, so Get-PiHoleDnsRecord's output can be
piped straight into it - including removing several matched records in
a single pipeline. This is the first use of pipeline input anywhere in
the module; no other function currently has a matching Get/Remove
object shape to make it worthwhile.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@mikemadeja mikemadeja changed the title feat: add Add-PiHoleDnsRecord and Remove-PiHoleDnsRecord feat: add Add/Remove/Get-PiHoleDnsRecord Oct 12, 2026
@mikemadeja
mikemadeja merged commit 4dfae38 into develop Oct 15, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant