identifying service connections for a

Aluri, Sreedhar 21 Reputation points
2022-02-18T23:53:12.4+00:00

Hi,

Is there a way to identify the service connection related to a particular subscription?

I tried something like this but I dont think its correct.

$Subscription = Get-AzSubscription
$Subscription | ForEach-Object {

$WarningPreference = 'SilentlyContinue';

$abc= Select-AzSubscription -Subscription $_

Get-AzRoleAssignment | Where-Object{$.RoleDefinitionName -eq "AcrPull" -and $.DisplayName -like "<String>"} | select Id, DisplayName, RoleDefinitionName, Scope

}

regards

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,504 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,293 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 107.5K Reputation points MVP
    2022-02-19T09:42:03.363+00:00

    Hi @Aluri, Sreedhar ,

    what is your understanding of service connection related to a particular subscription. Sorry, I don't get your requirement.
    Maybe you can put some context to it.

    You wrote "you don't think it's correct" ... What does this mean? Error messages are shown? Or the result doesn't meet your requirements/exceptions?

    The following script is working here (if I set the right values for $definitionName and $displayname ) with 4 subscriptions I have.

    $definitionName = "xxx"  
    $displayName = "yyy"  
    $WarningPreference = 'SilentlyContinue';  
    Get-AzSubscription |  ForEach-Object {  
      Select-AzSubscription -Subscription $_  
      Get-AzRoleAssignment |  
      Where-Object { $_.RoleDefinitionName -eq $definitionName -and $_.DisplayName -like $displayName } |  
      Select-Object ObjectId, DisplayName, RoleDefinitionName, Scope  
    }  
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.