Connect-AzAccount -Tenant 'xxxxx' -SubscriptionId 'xxxx'
# Get the Resource Group Name
$resourceGroupName = "city-app-rg-xx-uat"
# Get all Private Endpoints in the Resource Group
$privateEndpoints = Get-AzPrivateEndpoint -ResourceGroupName $resourceGroupName
# Create a list to store the data
$data = @()
# Loop through each Private Endpoint
foreach ($privateEndpoint in $privateEndpoints) {
$fqdn = $privateEndpoint.PrivateDnsZoneGroup.Name
$ipAddresses = $privateEndpoint.PrivateIPAddresses -join ","
$name = $privateEndpoint.Name
$data += [PSCustomObject]@{
FQDN = $fqdn
IPAddress = $ipAddresses
Name = $name
}
}
# Export the data to a CSV file
$data | Export-Csv -Path "PrivateEndpointDetails.csv" -NoTypeInformation
Output received:
In the output, the Fully Qualified Domain Name (Private endpoint URL) and the Private IPs of the azure resources are not printed in the output file.
Unable to identify what is wrong in the above PowerShell script.
Get Private FQDNs, IPs, Names of the Private Endpoints for the Azure resources deployed in an Virtual Network using PowerShell Script
Here is the updated PowerShell
script to fetch the private endpoint FQDN and Private IP address.
$dnsConfigData = @()
$privateEndpoints = Get-AzPrivateEndpoint -ResourceGroupName "Automation_RG"
foreach ($endpoint in $privateEndpoints) {
if ($endpoint.CustomDnsConfigsText) {
$dnsConfigs = $endpoint.CustomDnsConfigsText | ConvertFrom-Json
foreach ($config in $dnsConfigs) {
$PEfqdn = $config.Fqdn
$PEipAddresses = $config.IpAddresses -join ","
$dnsConfigData += [pscustomobject]@{
Fqdn = $PEfqdn
IpAddresses = $PEipAddresses
}
}
} else {
Write-Output "No Custom DNS Configs found for this endpoint."
}
}
$dnsConfigData | Export-Csv -Path "PrivateEndpointDnsdetails.csv" -NoTypeInformation -Encoding UTF8
Write-Output "CSV file created: PrivateEndpointDnsdetails.csv"
Output:
Excel Output