Bulk DNS modify | TXT record description

I got this code working to change the Description field of a DNS txt RR:

$oldvalue = Get-DnsServerResourceRecord -ZoneName ZoneName.com -ComputerName DNSSERVER -RRType Txt -Name _dmarc
$newvalue = Get-DnsServerResourceRecord -ZoneName ZoneName.com -ComputerName DNSSERVER -RRType Txt -Name _dmarc
$newvalue.RecordData.DescriptiveText = “v=DMARC1; p=none; fo=1; rua=mailto:dmarc_rua@emaildefense.point.com; ruf=mailto:dmarc_ruf@emaildefense.point.com”
Set-DnsServerResourceRecord -ZoneName ZoneName.com -ComputerName DNSSERVER -OldInputObject $oldvalue -NewInputObject $newvalue

…and I have a csv structured like this:

DomainName,DMARCRecordName,NewDMARCRecord
contoso.com.hk,_dmarc,"v=DMARC1; p=none; fo=1; rua=mailto:dmarc_rua@emaildefense.point.com; ruf=mailto:dmarc_ruf@emaildefense.point.com"

…How would you create a for each loop to set all my new descriptions?

you’re almost done.

you would use Import-Csv with a ForEach-object in the pipeline.

Import-Csv -Path <your csv path> | ForEach-Object -Process {
$oldvalue = Get-DnsServerResourceRecord -ZoneName ZoneName.com -ComputerName DNSSERVER -RRType Txt -Name $_.DMARRecordName
$NewValue = Get-DnsServerResourceRecord -ZoneName ZoneName.com -ComputerName DNSSERVER -RRType Txt -Name $_.DMARRecordName
# $_ has all the information you have in CSV. you can add the set dns rr code below.
}

Thank you…I got this working then with this:

Import-Csv -Path .\DMARC.csv  | ForEach-Object -Process {
$oldvalue = Get-DnsServerResourceRecord -ZoneName $_.DomainName -ComputerName DNSSERVER-RRType Txt -Name _dmarc
$NewValue = Get-DnsServerResourceRecord -ZoneName $_.DomainName -ComputerName DNSSERVER-RRType Txt -Name _dmarc
$newvalue.RecordData.DescriptiveText = $_."NewDMARCRecord”
Set-DnsServerResourceRecord -ZoneName $_.DomainName -ComputerName DNSSERVER-OldInputObject $oldvalue -NewInputObject $newvalue
}

I’d like help with a validation step, exporting the changed descriptions to a csv and tried this:

Import-Csv -Path .\DMARC.csv  | ForEach-Object -Process {
$CurrentValue = Get-DnsServerResourceRecord -ZoneName $_.DomainName -ComputerName DNSSERVER-RRType Txt -Name _dmarc
$CurrentValue.RecordData.DescriptiveText | Export-Csv -Path .\CurrentValue.csv -NoTypeInformation <---- wrong
### How do I then output all the changed descriptions to a .csv?

}