Easily get NS, MX, SPF, DMARC and DKIM records. PowerShell to the rescue...
In the world of IT, we're constantly striving to enhance an organization's security posture, resolve email deliverability woes, or simply bring their infrastructure up to par. A common task in this realm is the need to swiftly assess DNS configurations, especially during events like an acquisition where dozens—or even hundreds—of domains need to be scrutinized for their current settings.
While tools for this purpose undoubtedly exist, the unique challenges of each audit often necessitate a more tailored approach. Recently, during an acquisition involving over 50 domains, I found myself needing a more efficient way to gather critical DNS record information. This led to the development of two PowerShell scripts, designed to automate and simplify this often-tedious process. Full disclosure: These scripts were developed with significant assistance from Gemini, an AI.
Script 1: Comprehensive DNS Record Retrieval
This primary script is designed to handle the bulk of your DNS record discovery. It comes pre-loaded with a comprehensive list of common DKIM selectors, which should cover a wide range of scenarios. Should you encounter a less common selector, the script is easily modifiable to incorporate new findings.
Usage Examples:
For multiple domains from a file:
./Get-DNSRecords.ps1 -File "domains.txt"
For a single domain:
./Get-DNSRecords.ps1 -Domain "curtislamasters.com"
Detailed documentation and additional usage instructions are embedded directly within the script.
Script 2: Targeted DKIM Selector Discovery
Occasionally, you'll encounter domains using unconventional or obscure DKIM selector names. This secondary script is specifically designed to help identify these "needle in a haystack" selectors that might be missed by a more general scan.
Usage Examples (identical to the first script for consistency):
For multiple domains from a file:
./Get-DNSSelector.ps1 -File "domains.txt"
For a single domain:
./Get-DNSSelector.ps1 -Domain "curtislamasters.com"
Similar to the first script, comprehensive documentation is included within the script itself.
A Practical Workflow
My current workflow involves running Get-DNSRecords.ps1
first. If a DKIM selector isn't found, I then use Get-DNSSelector.ps1
to identify the elusive selector. Once found, I integrate that new selector into the Get-DNSRecords.ps1
script for future, more comprehensive scans. This iterative process has proven effective across hundreds of domain checks.
Technical Note: These scripts have been tested on PowerShell 7.5 running on both Windows 10 and Windows 11 with consistent results.
Future Enhancements
Looking ahead, I plan to explore transforming these scripts into a web application, making DNS record auditing even more accessible and user-friendly.
I welcome any feedback or suggestions on these scripts and the workflow. Your insights help refine and improve these tools for the benefit of the community.
Comments ()