Get DNS configuration from computer

#@
#based on our name convention eg. CHxxxxxx
#create the file with the servers
#$target = Get-ADComputer -filter * | Where-Object name -Like ‘CH*’ | Select-Object name | Out-File

$StartTime = (Get-Date)
#read the file that countains the servernames
$target = Get-Content

foreach($servername in $target){
if (Test-Connection $servername -Count 1 -Quiet){
$servername | out-file -Append
Get-DnsClientServerAddress -AddressFamily IPv4 | Select-Object –ExpandProperty ServerAddresses | out-file -Append
“####################” | out-file -Append
}

}
write-host “Script ran for : “$([timespan]::fromseconds(((Get-Date)-$StartTime).Totalseconds).ToString(“mm\:ss”))

Leave a Reply

Your email address will not be published. Required fields are marked *