Skip to content

Instantly share code, notes, and snippets.

@stopthatastronaut
Created May 25, 2017 02:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stopthatastronaut/0f8a6bb5d13061ac68030360739e077a to your computer and use it in GitHub Desktop.
Save stopthatastronaut/0f8a6bb5d13061ac68030360739e077a to your computer and use it in GitHub Desktop.
Get-R53ResourceRecordList
# 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