首页 > 解决方案 > 使用 powershell cmd-let/REST API 获取 Azure AD 审计日志

问题描述

我需要获取有关对目录角色所做更改的信息(例如全局管理员) 我需要详细信息,例如用户名 - A)进行更改的用户,B)时间戳,C)操作 - 将用户添加到组或删除,D ) 已添加用户的组的名称。我在 Azure 门户上更新了 AD 模块,现在我有了 AzureADPreview,并且我正在使用 cmd-let --> Get-AzureADAuditDirectoryLogs。作为输出,我只能得到:A)B)和C)。我检查了输出中的所有“Id”,但没有找到目录角色 ID。有没有使用提到的 PowerShell 命令捕获此信息的方法-> (D)?下面,我使用的命令:

Get-AzureADAuditDirectoryLogs -Filter "activityDateTime gt 2019-08-25" | where-object activitydisplayname -eq "Add member to group" | fl *
Get-AzureADAuditDirectoryLogs -Filter "activityDateTime gt 2019-09-01" | where-object activitydisplayname -eq "remove member from group"

更新:

我使用 Rest API 来获取所需的信息:

$request = "https://graph.windows.net/xxx.com/activities/audit?api-version=beta"

$authHeader = @{  
'Content-Type'='application/json'  
'Accept'='application/json'  
'Authorization'= ("Bearer $personalToken")  
}  

$output = Invoke-RestMethod -Uri $request -Method Get -ContentType "application/json" -Headers $authHeader  
$output.value  

在输出中,仍然看不到有关用户已添加到的组的信息。

标签: azureazure-active-directoryazure-powershellazure-ad-graph-api

解决方案


我不确定为什么不返回组的名称。

但是该组的对象 ID 将显示在结果中。

Azure AD 日志

用于Get-AzureADGroup -ObjectId {Object ID}获取其名称信息。


推荐阅读