AZ_MG_GROUP_READWRITE_ALL
Last updated
Was this helpful?
Was this helpful?
Connect-MgGraph -Scopes "Application.Read.All"
$permissionId = "62a82d76-70ea-41e2-9197-370581804d09" # Group.ReadWrite.All
$graphSp = Get-MgServicePrincipal -Filter "appId eq '00000003-0000-0000-c000-000000000000'"
Get-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalId $graphSp.Id -All | Where-Object { $_.AppRoleId -eq $permissionId } | ForEach-Object {
$sp = Get-MgServicePrincipal -ServicePrincipalId $_.PrincipalId
[PSCustomObject]@{ DisplayName = $sp.DisplayName; AppId = $sp.AppId }
} | Format-Table -AutoSizeConnect-MgGraph -Scopes "AuditLog.Read.All"
Get-MgAuditLogDirectoryAudit -Filter "activityDisplayName eq 'Add group' or activityDisplayName eq 'Delete group' or activityDisplayName eq 'Add member to group'" -Top 50 | ForEach-Object {
[PSCustomObject]@{
DateTime = $_.ActivityDateTime
Activity = $_.ActivityDisplayName
Actor = $_.InitiatedBy.App.DisplayName ?? $_.InitiatedBy.User.UserPrincipalName
Target = $_.TargetResources[0].DisplayName
}
} | Format-Table -AutoSize