Created
May 25, 2017 02:12
-
-
Save stopthatastronaut/0f8a6bb5d13061ac68030360739e077a to your computer and use it in GitHub Desktop.
Get-R53ResourceRecordList
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
# Gets all Route53 DNS records for the requested Zone | |
Function Get-R53ResourceRecordList | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[ValidateScript( | |
{ | |
$_ -like "*." | |
} | |
)] | |
$HostedZoneName | |
) | |
$hostedZone = Get-R53HostedZones | ? {$_.Name -eq $HostedZoneName} | |
$records = @() | |
$NextRecordName = Get-R53ResourceRecordSet -HostedZoneId $hostedZone.Id | select -expand ResourceRecordsets | select -first 1 | select -expand Name | |
do | |
{ | |
Write-Verbose "Retrieving 100 records starting at $nextrecordname" | |
$recordpage = Get-R53ResourceRecordSet -HostedZoneId $hostedZone.Id -StartRecordName $NextRecordName | |
$records += $recordpage.ResourceRecordSets | |
$nextrecordname = $recordpage.nextRecordName | |
} | |
while($NextRecordName -ne $null) | |
Write-Verbose (($records | measure | select -expand Count), "found." -join " ") | |
return $records | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment