PowerShell: Azure Traffic Manager Profiles with Endpoint details
The script uses the Azure Resource Graph query to get the resource details.
$trafficManagerQuery = "where type =~ 'microsoft.network/trafficmanagerprofiles'"
$trafficeManagers = Search-AzGraph -Query $trafficManagerQuery
$resultTM = @()
foreach($tm in $trafficeManagers)
{
$endPoints = $tm.properties.endpoints
foreach($endPoint in $endPoints)
{
$edTagetQuery = "where id =~ '{0}'" -f $endPoint.properties.targetResourceId
$endTarget = Search-AzGraph -Query $edTagetQuery
$customObjProperties = [ordered]@{
'Name' = $tm.name
'Status' = $tm.properties.profileStatus
'RoutingMethod' = $tm.properties.trafficRoutingMethod
'DNSName' = $tm.properties.dnsConfig.fqdn
'EndPointTarget' = $endPoint.properties.target
'EndPointStatus' = $endPoint.properties.endpointStatus
'EndPoinTargetResource' = `
$endTarget.Properties.ipConfiguration.id.split('/')[-4,-1] -join '/'
}
$customObjTM = New-Object -TypeName psobject -Property $customObjProperties
$resultTM += $customObjTM
}
}
$resultTM
Comments
Post a Comment