I'm using the below script:
Powershell script to get only specific Fields in an azure webapp But that appears not to complete the requirement.
I'm using the below script:
Powershell script to get only specific Fields in an azure webapp But that appears not to complete the requirement.
Below is the script that worked for me.
$PrivateEndPoints = Get-AzPrivateEndpoint
$Result=@()
For($I=0;$I -lt $PrivateEndPoints.count;$I++) {
$PrivateLinkServiceId = $PrivateEndPoints[$I].PrivateLinkServiceConnections.PrivateLinkServiceId
$SubnetId = $PrivateEndPoints[$I].Subnet.Id
$WebAppArray = $PrivateEndPoints[$I].PrivateLinkServiceConnections.PrivateLinkServiceId.ToLower() -split "/"
$SubnetArray = $SubnetId -split "/"
if(($WebAppArray -like "*Microsoft.Web*") -and ($SubnetId -like "*virtualNetworks*"))
{
For($J=0;$J -lt $SubnetArray.count;$J++){
$SubnetNameIndex = $SubnetArray.indexOf("subnets") + 1
$SubnetName = $SubnetArray[$SubnetNameIndex]
}
For($J=0;$J -lt $SubnetArray.count;$J++){
$VnetNameIndex = $SubnetArray.indexOf("virtualNetworks") + 1
$VnetName = $SubnetArray[$VnetNameIndex]
}
For($J=0;$J -lt $WebAppArray.count;$J++){
$WebAppNameIndex = $WebAppArray.indexOf("sites") + 1
$WebAppName = $WebAppArray[$WebAppNameIndex]
}
$obj = [PSCustomObject]@{
WebAppName = $WebAppName
PrivateEndpointName = $PrivateEndPoints[$I].Name
VnetName = $VnetName
Subnets = $SubnetName
}
$Result+=$obj
}
}
$Result
RESULTS:
