I have the script below.
$log = "C:\DNSLog.txt"
############ GET THE LIST OF RECORDS
$zones = Get-Content "C:\dnslist.txt"
############ TRANSFER THE ZONES TO THE MASTER SERVER
Write-Host "Transferring the zones to the master server..."
foreach ($zone in $zones) {
Write-Host $zone >> $log
dnscmd . /zoneadd $zone /Secondary 10.x.x.x >> $log
}
This doesn't seem to be outputting what I need to the log file. All I am getting is the "write-host" portion. No feedback from the "dnscmd" command. I would expect to see this (because the zone already exists in this case, but you get the point for success/failure):
domain1.com
Command failed: DNS_ERROR_ZONE_ALREADY_EXISTS 9609 0x2589
If I just do:
Write-Host $zone
dnscmd . /zoneadd $zone /Secondary 10.x.x.x >> $log
I get the dnscmd output and no "write-host" feedback (as expected). What am I doing wrong that won't let me get the "write-host AND the dnscmd output in the log file???
Many thanks!