admin管理员组

文章数量:1323731

How can I filter for a specific IP address through the Microsoft Entra Audit logs?

I tried following two PowerShell commands:

Get-MgAuditLogDirectoryAudit -All -Property * -Filter "initiatedBy/user/ipAddress eq '$IpAddress'"
Get-MgBetaAuditLogDirectoryAudit -All -Property * -Filter "initiatedBy/user/ipAddress eq '$IpAddress'"

Following filter query works:

Get-MgAuditLogDirectoryAudit -All -Property * -Filter "initiatedBy/user/userPrincipalName eq '$UPN'"

How can I filter for a specific IP address through the Microsoft Entra Audit logs?

I tried following two PowerShell commands:

Get-MgAuditLogDirectoryAudit -All -Property * -Filter "initiatedBy/user/ipAddress eq '$IpAddress'"
Get-MgBetaAuditLogDirectoryAudit -All -Property * -Filter "initiatedBy/user/ipAddress eq '$IpAddress'"

Following filter query works:

Get-MgAuditLogDirectoryAudit -All -Property * -Filter "initiatedBy/user/userPrincipalName eq '$UPN'"
Share Improve this question edited Jan 12 at 6:20 user3022917 asked Jan 12 at 6:14 user3022917user3022917 6172 gold badges11 silver badges21 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 1

See the API documentation, they never state that filtering on ipAddress is supported:

Indicates information about the user or app initiated the activity. Supports $filter (eq) for user/id, user/displayName, user/userPrincipalName, app/appId, app/displayName; and $filter (startswith) for user/userPrincipalName.

If you want to filter by ipAddress server side you can do so via KQL query to AuditLogs table assuming you're storing the logs in Log Analytics or Azure Data Explorer, i.e.:

AuditLogs
| where initiatedBy.user.ipAddress == "$IpAddress"

My current attempt:

Get-MgAuditLogDirectoryAudit -All -Property * -Search '"ipAddress:$IpAddress"'

But it seems that the results are bogus.

My solution:

[Array]$Records = Get-MgBetaAuditLogDirectoryAudit -All
$Records | Where-Object {$_.InitiatedBy.User.IPAddress -eq "$IpAddress"}

Why not using the logs you already paid for?
Who wants to invest extra money for LogAnalytics, Splunk, etc. can do this. ;-)

本文标签: