Email security & monitoring
DKIM Selector Check
Queries the common DKIM selectors (default, s1/s2, selector1/2) for a domain via DNS and reports which records exist.
Replace generic placeholder values (tenant, domain, secrets) for your own environment before running. Read it first and test safely.
# List of potential selectors to check
$selectors = @('default', 's1', 's2', 'selector1', 'selector2')
# Domain to check
$domain = "example.com"
# Function to query DKIM record for a given selector
function Query-Dkim {
param (
[string]$selector,
[string]$domain
)
$record = "$selector._domainkey.$domain"
try {
$result = Resolve-DnsName -Name $record -Type TXT -ErrorAction Stop
if ($result) {
Write-Output "Found DKIM record for ${record}: $(($result.Strings) -join '')"
}
} catch {
Write-Output "No DKIM record found for ${record}"
}
}
# Check each selector
foreach ($selector in $selectors) {
Query-Dkim -selector $selector -domain $domain
}