Skip to content

Instantly share code, notes, and snippets.

@RumataEstor
Last active July 20, 2017 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RumataEstor/f6b0a3d43f5edb600378d9c111a092c0 to your computer and use it in GitHub Desktop.
Save RumataEstor/f6b0a3d43f5edb600378d9c111a092c0 to your computer and use it in GitHub Desktop.
Migrate Active Directory DNS records from subdomain
Get-DnsServerResourceRecord -ZoneName $zone -RRType A | Where-Object {$_.HostName.EndsWith("." + $sub)} | ForEach {Add-DnsServerResourceRecordA -ZoneName ($sub + "." + $zone) -Name $_.HostName.Remove($_.HostName.Length - 1 - $sub.Length) -IPv4Address $_.RecordData.IPv4Address -TimeToLive $_.TimeToLive -AllowUpdateAny -AgeRecord}
Get-DnsServerResourceRecord -ZoneName $zone -RRType CName | Where-Object {$_.HostName.EndsWith("." + $sub)} | ForEach {Add-DnsServerResourceRecordCName -ZoneName ($sub + "." + $zone) -Name $_.HostName.Remove($_.HostName.Length - 1 - $sub.Length) -HostNameAlias $_.RecordData.HostNameAlias -TimeToLive $_.TimeToLive}
Get-DnsServerResourceRecord -ZoneName $zone -RRType SRV | Where-Object {$_.HostName.EndsWith("." + $sub)} | ForEach {Add-DnsServerResourceRecord -Srv -ZoneName ($sub + "." + $zone) -Name $_.HostName.Remove($_.HostName.Length - 1 - $sub.Length) -DomainName $_.RecordData.DomainName -Port $_.RecordData.Port -TimeToLive $_.TimeToLive -Weight $_.RecordData.Weight -Priority $_.RecordData.Priority}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment