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"