DNSRobot.psm1
|
$script:BaseUrl = 'https://dnsrobot.net/api' $script:UserAgent = 'dnsrobot-powershell/0.1.0' function Invoke-DnsRobotApi { param( [string]$Endpoint, [string]$Method = 'POST', [hashtable]$Body ) $params = @{ Uri = "$script:BaseUrl/$Endpoint" Method = $Method ContentType = 'application/json' UserAgent = $script:UserAgent } if ($Body) { $params['Body'] = ($Body | ConvertTo-Json -Compress) } $response = Invoke-RestMethod @params return $response } function Invoke-DnsRobotLookup { <# .SYNOPSIS DNS record lookup via DNS Robot (https://dnsrobot.net/dns-lookup). .DESCRIPTION Queries DNS records for a domain. Supports A, AAAA, MX, TXT, CNAME, NS, SOA, PTR, and more. Powered by DNS Robot — 53 free online DNS and network tools at https://dnsrobot.net. .PARAMETER Domain The domain name to look up. .PARAMETER RecordType DNS record type (default: A). Options: A, AAAA, MX, TXT, CNAME, NS, SOA, PTR, SRV, CAA. .PARAMETER DnsServer DNS server to query (default: 8.8.8.8). .EXAMPLE Invoke-DnsRobotLookup -Domain "example.com" -RecordType "MX" .LINK https://dnsrobot.net/dns-lookup #> param( [Parameter(Mandatory)][string]$Domain, [string]$RecordType = 'A', [string]$DnsServer = '8.8.8.8' ) Invoke-DnsRobotApi -Endpoint 'dns-query' -Body @{ domain = $Domain recordType = $RecordType dnsServer = $DnsServer } } function Invoke-DnsRobotWhois { <# .SYNOPSIS WHOIS domain registration lookup via DNS Robot (https://dnsrobot.net/whois-lookup). .DESCRIPTION Retrieves WHOIS registration data including registrar, creation date, expiry date, and nameservers. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER Domain The domain name to look up. .EXAMPLE Invoke-DnsRobotWhois -Domain "example.com" .LINK https://dnsrobot.net/whois-lookup #> param([Parameter(Mandatory)][string]$Domain) Invoke-DnsRobotApi -Endpoint 'whois' -Body @{ domain = $Domain } } function Invoke-DnsRobotSslCheck { <# .SYNOPSIS SSL/TLS certificate check via DNS Robot (https://dnsrobot.net/ssl-checker). .DESCRIPTION Validates SSL/TLS certificates including issuer, expiry, chain, and protocol support. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER Domain The domain name to check. .EXAMPLE Invoke-DnsRobotSslCheck -Domain "example.com" .LINK https://dnsrobot.net/ssl-checker #> param([Parameter(Mandatory)][string]$Domain) Invoke-DnsRobotApi -Endpoint 'ssl-certificate' -Body @{ domain = $Domain } } function Invoke-DnsRobotSpfCheck { <# .SYNOPSIS SPF record validation via DNS Robot (https://dnsrobot.net/spf-checker). .DESCRIPTION Validates SPF (Sender Policy Framework) records for email authentication. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER Domain The domain name to check. .EXAMPLE Invoke-DnsRobotSpfCheck -Domain "example.com" .LINK https://dnsrobot.net/spf-checker #> param([Parameter(Mandatory)][string]$Domain) Invoke-DnsRobotApi -Endpoint 'spf-checker' -Body @{ domain = $Domain } } function Invoke-DnsRobotDkimCheck { <# .SYNOPSIS DKIM record check via DNS Robot (https://dnsrobot.net/dkim-checker). .DESCRIPTION Validates DKIM (DomainKeys Identified Mail) records for email authentication. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER Domain The domain name to check. .PARAMETER Selector DKIM selector (optional). .EXAMPLE Invoke-DnsRobotDkimCheck -Domain "example.com" -Selector "google" .LINK https://dnsrobot.net/dkim-checker #> param( [Parameter(Mandatory)][string]$Domain, [string]$Selector ) $body = @{ domain = $Domain } if ($Selector) { $body['selector'] = $Selector } Invoke-DnsRobotApi -Endpoint 'dkim-checker' -Body $body } function Invoke-DnsRobotDmarcCheck { <# .SYNOPSIS DMARC record check via DNS Robot (https://dnsrobot.net/dmarc-checker). .DESCRIPTION Validates DMARC (Domain-based Message Authentication) records and policies. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER Domain The domain name to check. .EXAMPLE Invoke-DnsRobotDmarcCheck -Domain "example.com" .LINK https://dnsrobot.net/dmarc-checker #> param([Parameter(Mandatory)][string]$Domain) Invoke-DnsRobotApi -Endpoint 'dmarc-checker' -Body @{ domain = $Domain } } function Invoke-DnsRobotMxLookup { <# .SYNOPSIS MX record lookup via DNS Robot (https://dnsrobot.net/mx-lookup). .DESCRIPTION Retrieves mail exchange (MX) records with priority and hostname. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER Domain The domain name to look up. .EXAMPLE Invoke-DnsRobotMxLookup -Domain "example.com" .LINK https://dnsrobot.net/mx-lookup #> param([Parameter(Mandatory)][string]$Domain) Invoke-DnsRobotApi -Endpoint 'mx-lookup' -Body @{ domain = $Domain } } function Invoke-DnsRobotNsLookup { <# .SYNOPSIS Nameserver lookup via DNS Robot (https://dnsrobot.net/ns-lookup). .DESCRIPTION Retrieves nameserver (NS) records for a domain. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER Domain The domain name to look up. .EXAMPLE Invoke-DnsRobotNsLookup -Domain "example.com" .LINK https://dnsrobot.net/ns-lookup #> param([Parameter(Mandatory)][string]$Domain) Invoke-DnsRobotApi -Endpoint 'ns-lookup' -Body @{ domain = $Domain } } function Invoke-DnsRobotIpLookup { <# .SYNOPSIS IP geolocation lookup via DNS Robot (https://dnsrobot.net/ip-lookup). .DESCRIPTION Returns geolocation, ASN, ISP, and organization data for an IP address. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER IP The IP address to look up. .EXAMPLE Invoke-DnsRobotIpLookup -IP "8.8.8.8" .LINK https://dnsrobot.net/ip-lookup #> param([Parameter(Mandatory)][string]$IP) Invoke-DnsRobotApi -Endpoint 'ip-info' -Body @{ ip = $IP } } function Invoke-DnsRobotHttpHeaders { <# .SYNOPSIS HTTP response headers check via DNS Robot (https://dnsrobot.net/http-headers-checker). .DESCRIPTION Analyzes HTTP response headers including security headers, caching, and server info. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER Url The URL to check. .EXAMPLE Invoke-DnsRobotHttpHeaders -Url "https://example.com" .LINK https://dnsrobot.net/http-headers-checker #> param([Parameter(Mandatory)][string]$Url) if (-not ($Url -match '^https?://')) { $Url = "https://$Url" } Invoke-DnsRobotApi -Endpoint 'http-headers' -Body @{ url = $Url } } function Invoke-DnsRobotPortCheck { <# .SYNOPSIS Port availability check via DNS Robot (https://dnsrobot.net/port-checker). .DESCRIPTION Tests whether a specific TCP port is open on a host. Powered by DNS Robot — https://dnsrobot.net. .PARAMETER Host The hostname or IP to check. .PARAMETER Port The port number to test. .EXAMPLE Invoke-DnsRobotPortCheck -Host "example.com" -Port 443 .LINK https://dnsrobot.net/port-checker #> param( [Parameter(Mandatory)][string]$Host, [Parameter(Mandatory)][int]$Port ) Invoke-DnsRobotApi -Endpoint "port-check?host=$Host&port=$Port" -Method 'GET' } |