0

我需要为具有 3 天以上的高级访问权限的用户生成警报,例如向管理员发送邮件。我可以使用命令找到用户详细信息,例如 DisplayName、SignInName、RoleDefinitionName Get-AzureRmRoleAssignment,但问题是我如何知道该用户何时分配此角色的时间戳。请帮助我使用 powershell 脚本来查找在 azure 中为用户分配此角色(例如所有者)的时间戳。

4

1 回答 1

0

使用Get-AzureRmLog获取 Azure RBAC 更改的活动日志。请注意,日志只能保留 90 天。

例如:

#get the role assignment
$ra = Get-AzureRmRoleAssignment -ObjectId 256d1966-019b-479c-a71f-d5a1xxxxxx43
#find the role assignment id, for example: $ra[1].RoleAssignmentId
$ra[1].RoleAssignmentId
#get the azureRm log in the past 10 days by filtering with resource id
$rmlog = Get-AzureRmLog -ResourceProvider Microsoft.Authorization -StartTime (Get-Date).AddDays(-10) | Where-Object{$_.ResourceId -eq $ra[1].RoleAssignmentId} 
#get the SubmissionTimestamp and EventTimestamp, see which one is what you want
$rmlog.SubmissionTimestamp
$rmlog.EventTimestamp
于 2020-11-20T00:59:23.020 回答