-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-PrivateEndpoint.ps1
36 lines (33 loc) · 1.84 KB
/
Get-PrivateEndpoint.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$Subs = Get-AzSubscription
$OutputList = @()
try {
Foreach ($Sub in $Subs) {
Set-AzContext -Subscription $Sub.id *>$null
$PrivateEndpoints = Get-AzPrivateEndpoint
foreach ($PrivateEndpoint in $PrivateEndpoints) {
$PrivateEndpointName = $PrivateEndpoint.Name
$PrivateEndpointRG = $PrivateEndpoint.ResourceGroupName
$PrivateEndpointSubResource = ($PrivateEndpoint.PrivateLinkServiceConnectionsText | ConvertFrom-Json).GroupIDs -Join ", "
$PrivateEndpointIPs = $PrivateEndpoint.CustomDnsConfigs.IpAddresses -Join ", "
$PrivateEndpointResource = ($PrivateEndpoint.Id -split("/"))[-1]
$PrivateEndpointVNET = ((($PrivateEndpoint.SubnetText | ConvertFrom-Json).Id) -split("/"))[8] + "/" + ((($PrivateEndpoint.SubnetText | ConvertFrom-Json).Id) -split("/"))[10]
#$PrivateEndpointVNET
#($PrivateEndpoint.SubnetText | ConvertFrom-Json).Id
$PED = New-Object -Type PSObject
$PED | Add-Member -Name 'PrivateEndpointName' -Type NoteProperty -Value $PrivateEndpointName
$PED | Add-Member -Name 'PrivateEndpointRG-' -Type NoteProperty -Value $PrivateEndpointRG
$PED | Add-Member -Name 'PrivateEndpointSubResource' -Type NoteProperty -Value $PrivateEndpointSubResource
$PED | Add-Member -Name 'PrivateEndpointIPs' -Type NoteProperty -Value $PrivateEndpointIPs
$PED | Add-Member -Name 'PrivateEndpointResource' -Type NoteProperty -Value $PrivateEndpointResource
$PED | Add-Member -Name 'PrivateEndpointVNET' -Type NoteProperty -Value $PrivateEndpointVNET
$OutputList += $PED
}
}
}
catch
{
Write-Error -Message $_.Exception
throw $_.Exception
}
$OutputList | Export-Csv -Path PrivateEndpoints.csv -NoTypeInformation
$OutputList | ogv