dns.psm1
function Resolve-CustomDnsName { [CmdletBinding()] Param ( [Parameter(Mandatory=$true)] [string]$Hostname, [Parameter(Mandatory=$false)] [string]$DNSServer = "8.8.8.8", # Default to Google's DNS [Parameter(Mandatory=$false)] [ValidateSet("A", "AAAA", "MX", "TXT", "NS", "SOA", "PTR", "CNAME", "SRV", "ANY")] [string]$QueryType = "A" ) Process { try { # Use the Resolve-DnsName cmdlet with the provided parameters, without TimeoutSeconds $results = Resolve-DnsName -Name $Hostname -Type $QueryType -Server $DNSServer -ErrorAction Stop # Output the results return $results } catch { Write-Error "Failed to resolve DNS name: $_" } } } # EXAMPLE # Resolve-CustomDnsName -Hostname "example.com" -DNSServer "8.8.8.8" -QueryType "A" # ------------------------------------------------------------------------------------------------------------------------------- function Get-DnsSecStatus { [CmdletBinding()] Param( [Parameter(Mandatory=$true)] [string]$Domain, [Parameter(Mandatory=$false)] [string]$DNSServer = "8.8.8.8" # Google's public DNS server ) Process { try { # Query for DNSKEY record, which should exist if DNSSEC is enabled $dnskey = Resolve-DnsName -Name $Domain -Type DNSKEY -Server $DNSServer -DnsOnly -ErrorAction Stop if ($dnskey) { $status = "DNSSEC is enabled for the domain $Domain." # Optionally, you can add more checks here for detailed verification, like checking DS records in the parent zone, etc. } } catch { # If the DNSKEY query fails, it may indicate that DNSSEC is not enabled or not properly configured $status = "DNSSEC is not enabled or not properly configured for the domain $Domain." } Write-Output $status } } # EXAMPLE # Get-DnsSecStatus -Domain "example.com" |