skip to Main Content

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?

2

Answers


  1. 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*" }
    
    Login or Signup to reply.
  2. We have also tried the same and getting the same issue as you and tried with below where object format with id and it worked.

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

    Nothing displayed:-

    enter image description here

    SUCCESFULLY GETTING DETAILS:-

    enter image description here

    Alternatively we can use the Given REST API here to get the same by using our private connection name:-

    enter image description here

    STORAGE ACCOUNT DETAILS WITH PRIVATE ENDPOINTS:-

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search