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