Skip to content

Instantly share code, notes, and snippets.

@Rugby-Ball
Created September 6, 2023 17:20
Show Gist options
  • Save Rugby-Ball/490ffb0c2c5a84a788343dc73d42f1c0 to your computer and use it in GitHub Desktop.
Save Rugby-Ball/490ffb0c2c5a84a788343dc73d42f1c0 to your computer and use it in GitHub Desktop.
Pull an Inventory of all Cloudfront distributions across all regions. Export to a CSV file. You will see the regions a CloudFront distribution is in. #Public #Utility #Inventory #AWS #CloudFront
#CloudFront-Distro-List-ALL-Regions.ps1
<#
Description: Pull an Inventory of all Cloudfront distributions across all regions. Export to a CSV file.
You will see the regions a CloudFront distribution is in.
Written: Ed Walsh
PowerShell.Core tested: Yes
MS-Graph: No
Version: 1.0
Create Date: 9/6/2023
Revised Date: 9/6/2023
#>
##Check if c:\temp exists, if it doesnt create it.
If (-not(Test-Path -Path "c:\temp"))
{ New-Item -ItemType Directory -Force -Path C:\temp }
$Out = @()
Get-EC2Region -RegionToCall us-east-1 <# -RegionToCall used because of https://github.com/aws/aws-tools-for-powershell/issues/46 #> | Foreach-Object {
$region = $_.RegionName
$Out += Get-CFDistributionList -region $region | Select-Object @{name = "Region"; e = {$Region} }, ARN, Comment, DomainName, Enabled, Status, @{name = "Aliases"; expression = {($_.Aliases).Items -join "; "} }, @{name = "ACMCertificateArn"; e= {($_.ViewerCertificate).ACMCertificateArn} }, @{name = "Security_Policy"; e= {($_.ViewerCertificate).MinimumProtocolVersion } }
}
$Out | sort-object ARN, Region | Export-Csv -NoTypeInformation -Path c:\temp\CloudFront-Distro-List-ALL-Regions-$(get-date -f yyyyMMdd-hhmm-tt).csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment