Home > other >  How to find specific private endpoint in azure powershell
How to find specific private endpoint in azure powershell

Time:06-01

I'm running this command in azure to pull private endpoints associated to a storage account:

Get-AzPrivateEndpointConnection -privatelinkresourceid /subscriptions/subscriptionID/resourceGroups/rgname/providers/Microsoft.Storage/storageAccounts/storageaccountname

It returns results that look like the following:

Name                              : storageaccountname.93jd9v4a-84d3-942z-9g32-3895820193842
Id                                : /subscriptions/SubscriptionID/resourceGroups/rgname/providers/Microsoft.Storage/storageAccounts/storageaccountname/privateEndp
                                ointConnections/storageaccountname.93jd9v4a-84d3-942z-9g32-3895820193842
GroupId                           : 
ProvisioningState                 : Succeeded
PrivateEndpoint                   : {
                                  "Id": "/subscriptions/SubscriptionID/resourceGroups/rgname/providers/Microsoft.Network/privateEndpoints/PE1"
                                }
PrivateLinkServiceConnectionState : {
                                  "Status": "Pending",
                                  "Description": ""
                                }
LinkIdentifier                    : 

Name                              : storageaccountname.840ar94v-492s-594v-942s-49204816482941a
Id                                : /subscriptions/subscriptionID/resourceGroups/rgname/providers/Microsoft.Storage/storageAccounts/storageaccountname/privateEndp
                                ointConnections/storageaccountname.840ar94v-492s-594v-942s-49204816482941a
GroupId                           : 
ProvisioningState                 : Succeeded
PrivateEndpoint                   : {
                                  "Id": "/subscriptions/subscriptionID/resourceGroups/rgname/providers/Microsoft.Network/privateEndpoints/PE2"
                                }
PrivateLinkServiceConnectionState : {
                                  "Status": "Approved",
                                  "Description": "2022-05-23: approved"
                                }
LinkIdentifier                    : 

I want it to return just the one that has PE2 in the "PrivateEndpoint" parameter, so I run:

Get-AzPrivateEndpointConnection -privatelinkresourceid /subscriptions/subscriptionID/resourceGroups/rgname/providers/Microsoft.Storage/storageAccounts/storageaccountname | where-object privateendpoint -like "*PE2*"

But it doesn't return anything. If I run...:

Get-AzPrivateEndpointConnection -privatelinkresourceid /subscriptions/subscriptionID/resourceGroups/rgname/providers/Microsoft.Storage/storageAccounts/storageaccountname | where-object privateendpoint -like "*"

...it returns them all.

How can I use where-object to return just the PrivateEndpoint with PE2?

CodePudding user response:

I don't have any private endpoints to query but looking at the structure of the object it looks like you need the value of Id.

Where-Object { $_.privateendpoint.Id -like "*PE2*" }

CodePudding user response:

We have also tried the same and getting the same issue as you and tried with below enter image description here

SUCCESFULLY GETTING DETAILS:-

enter image description here

Alternatively we can use the Given enter image description here

STORAGE ACCOUNT DETAILS WITH PRIVATE ENDPOINTS:-

enter image description here

  • Related