如果您在Azure中分配角色,然后在删除角色分配之前删除身份,则会以“未找到身份”结束。健康)状况。它是无害的,但是它占据了角色分配插槽并缩小角色分配列表。我想找到并删除这些。
我认为这是这样的:
Get-AzRoleAssignment | Where-object -Property Displayname -eq $null
...将使我无关的身份而掌握这些角色,而且似乎有效,但是Azure Docs并没有真正保证这将涵盖所有案例。
我应该添加其他东西吗?还是有更好的方法可以找到这些角色分配?
If you assign a role in Azure and later delete the identity before you delete the role assignment, you wind up with an "Identity not found." condition. It's harmless, but it takes up a role assignment slot and clutters the role assignments list. I would like to find and delete these.
I am thinking that this:
Get-AzRoleAssignment | Where-object -Property Displayname -eq $null
...will get me those roles without an associated identity, and it seems to work, but the Azure docs don't really create much of an assurance that this will cover all cases.
Should I add something else to this? Or is there a better way of finding these roles assignments?
发布评论
评论(2)
事实证明,这种是是间接识别这些孤立角色分配的方法。但是,除非您有许可获得所有这些角色,否则您将无法删除这些孤立的角色分配。
Turns out this is the way to identify these orphaned role assignments, albeit indirectly. However, you will not be able to remove these orphaned role assignments unless you have the permission to get to all of them.
可以对此进行修改以完成所有孤立的角色分配,无论它是哪个角色,但这是我投入一些参数的管道中的大部分工作。
我使用作为起点。我选择不迭代订阅(这是我的管道中的参数)。
在管道YAML中使用PowerShell任务:
请注意,根据文档,需要objectID(或signInname/serviceprincipalname),roledefinitionName和范围。
This could be modified to do all orphaned role assignments, regardless of which role it is, but here's the bulk of work I put into a pipeline that takes some parameters.
I used this post as a starting point. I chose to NOT iterate over subscriptions (It's a parameter in my pipeline).
Using powershell task in pipeline yaml:
Note that according to documentation, ObjectId (or SignInName/ServicePrincipalName), RoleDefinitionName, and Scope are required.