Query common DNS record types from PowerShell
Build a paste-ready command, then review its compatibility and effects before running it.
'A','AAAA','MX','NS','TXT','CAA' | ForEach-Object { Resolve-DnsName <domain> -Type $_ -ErrorAction SilentlyContinue | Select-Object @{N='Type';E={$_.Type}},Name,IPAddress,NameExchange,Strings }Complete required fields to copy the generated command.
Compatibility
WindowsVerified for Windows using powershell syntax.
Operational knowledgereview due 2027-01-19
Requirementsshellshell must be installed and available on PATH.Network accessThe target must be reachable from the current environment.
Version supportshell Current supported releasesVerified for windows using powershell syntax; consult compatibility notes for platform-specific differences.
Expected signalsType Name IPAddress NameExchangeRepresentative successful output; values vary with the selected target and system state.
Known errorsshell: command not foundshell is missing or is not available on PATH.
Verify'A','AAAA','MX','NS','TXT','CAA' | ForEach-Object { Resolve-DnsName {{domain}} -Type $_ -ErrorAction SilentlyContinue | Select-Object @{N='Type';E={$_.Type}},Name,IPAddress,NameExchange,Strings }The output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01'A'CommandRuns the 'A' stage of this one-liner.
02,'AAAA','MX','NS','TXT','CAA'ArgumentPasses ,'AAAA','MX','NS','TXT','CAA' to 'A'.
03|PipelinePasses the output on the left to the command on the right.
04ForEach-ObjectCommandRuns the ForEach-Object stage of this one-liner.
05{ArgumentPasses { to ForEach-Object.
06Resolve-DnsNameArgumentPasses Resolve-DnsName to ForEach-Object.
07<domain>ParameterA value supplied in the Fill parameters section.
08-TypeOptionConfigures ForEach-Object with the -Type option.
09$_VariableExpands a value from the current shell environment or loop.
10-ErrorActionOptionConfigures ForEach-Object with the -ErrorAction option.
11SilentlyContinueArgumentPasses SilentlyContinue to ForEach-Object.
12|PipelinePasses the output on the left to the command on the right.
13Select-ObjectCommandRuns the Select-Object stage of this one-liner.
14@{N='Type'ArgumentPasses @{N='Type' to Select-Object.
15;Command separatorEnds this shell statement before the next one begins.
16E={$_.Type}},Name,IPAddress,NameExchange,StringsVariable assignmentSets a value used by the commands that follow.
17}CommandRuns the } stage of this one-liner.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
'A','AAAA','MX','NS' | ForEach-Object { Resolve-DnsName example.com -Type $_ -ErrorAction SilentlyContinue | Select-Object @{N='Type';E={$_.Type}},Name,IPAddress,NameExchange }
Example output
Type Name IPAddress NameExchange
---- ---- --------- ------------
A example.com 93.184.216.34
AAAA example.com 2606:2800:220:1:248:1893:25c8:1946
MX example.com .
Illustrative output — exact values vary by system and data.
Official sources