Link to home
Start Free TrialLog in
Avatar of Jeff Shafer
Jeff Shafer

asked on

Remove-DnsServerZone not working with CSV.

I am trying to clean up DNS and remove a ton of worthless Primary and Secondary zones on several 2012R2 servers. We have been playing with this PS but cannot get it to work properly.

$CSV = Import-Csv -Path "C:\_scripts\DNS\DelZones.csv"
foreach ($zone in $csv)
{ Remove-DnsServerZone -name $Zone -PassThru -verbose -whatif}

What we get back is when running it is:
Remove-DnsServerZone : The zone @{Zone=DummyZone.Dum} was not found on server DNS-03

So DummyZone.Dum is listed in the CSV and is hosted on DNS-03, so it seems to read the CVS, but adds @ and brackets {} which causes it to not be found. Any suggestions on how to fix this? I have used the command successfully with a single domain just not with the CSV.

Or if you have a different approach that would be great as well. Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeff Shafer
Jeff Shafer

ASKER

Worked perfectly thanks!