'Resolve-DNSName get errors to separate file
I'm trying to get all the errors to a separate file so that we can clean up the DNS srv later.
What I do want is to get the error message:
+ CategoryInfo : ResourceUnavailable: (bonjour.Domainname.com:String) [Resolve-DnsName], Win32Exception
+ FullyQualifiedErrorId : DNS_ERROR_RCODE_NAME_ERROR,Microsoft.DnsClient.Commands.ResolveDnsName
Resolve-DnsName : Domainname.com : DNS-namnet does not exist
to end up in a separate file, is this possible?
I'm using this script at the moment:
$path = ".\domain.txt"
$dnsserver = @('DNS-Srv1', 'DNS-Srv2' , 'DNS-Srv3')
$mxdomain = Get-Content $path
foreach ($domain in $mxdomain) {
Resolve-DnsName -Name $domain -Type MX -Server $dnsserver | select Name,Type,NameExchange } ```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
