Last active
July 20, 2017 04:33
-
-
Save RumataEstor/f6b0a3d43f5edb600378d9c111a092c0 to your computer and use it in GitHub Desktop.
Migrate Active Directory DNS records from subdomain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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