Microsoft Entra ID Protection 和 Microsoft Graph PowerShell

Microsoft Graph 是 Microsoft 统一的 API 端点和 Microsoft Entra ID 保护 API 的主页。 本文介绍如何使用 Microsoft Graph PowerShell SDK 通过 PowerShell 管理有风险的用户。 想要直接查询 Microsoft Graph API 的组织可以使用文章: 使用 Microsoft Graph API 识别和修正风险 ,以开始这一旅程。

先决条件

若要使用本文中的 PowerShell 命令,需要满足以下先决条件:

  • 已安装 Microsoft Graph PowerShell SDK。

  • 安全管理员 角色。

  • IdentityRiskEvent.Read.AllIdentityRiskyUser.ReadWrite.AllIdentityRiskyUser.ReadWrite.All 委托的权限是必需的。

    • 若要设置权限为 IdentityRiskEvent.Read.AllIdentityRiskyUser.ReadWrite.All,请运行以下命令:
    Connect-MgGraph -Scopes "IdentityRiskEvent.Read.All","IdentityRiskyUser.ReadWrite.All"
    
  • 如果使用仅限应用的身份验证,请参阅 将仅限应用的身份验证与 Microsoft Graph PowerShell SDK 配合使用

    • 若要使用所需的应用程序权限注册应用程序,请准备证书并运行:
    Connect-MgGraph -ClientID YOUR_APP_ID -TenantId YOUR_TENANT_ID -CertificateName YOUR_CERT_SUBJECT ## Or -CertificateThumbprint instead of -CertificateName
    

使用 PowerShell 列出风险检测

可以通过 ID 保护中风险检测的属性检索风险检测。

# List all anonymizedIPAddress risk detections
Get-MgRiskDetection -Filter "RiskType eq 'anonymizedIPAddress'" | Format-Table UserDisplayName, RiskType, RiskLevel, DetectedDateTime

# List all high risk detections for the user 'User01'
Get-MgRiskDetection -Filter "UserDisplayName eq 'User01' and RiskLevel eq 'high'" | Format-Table UserDisplayName, RiskType, RiskLevel, DetectedDateTime

使用 PowerShell 列出有风险的用户

可以在 ID 保护中检索有风险的用户及其风险历史记录。

# List all high risk users
Get-MgRiskyUser -Filter "RiskLevel eq 'high'" | Format-Table UserDisplayName, RiskDetail, RiskLevel, RiskLastUpdatedDateTime

#  List history of a specific user with detailed risk detection
Get-MgRiskyUserHistory -RiskyUserId 00aa00aa-bb11-cc22-dd33-44ee44ee44ee | Format-Table RiskDetail, RiskLastUpdatedDateTime, @{N="RiskDetection";E={($_). Activity.RiskEventTypes}}, RiskState, UserDisplayName

使用 PowerShell 确认用户是否遭到入侵

可以确认用户遭到入侵,并在 ID 保护中将其标记为高风险用户。

# Confirm Compromised on two users
Confirm-MgRiskyUserCompromised -UserIds "11bb11bb-cc22-dd33-ee44-55ff55ff55ff","22cc22cc-dd33-ee44-ff55-66aa66aa66aa"

使用 PowerShell 消除有风险的用户

可以在 ID 保护中批量消除有风险的用户。

# Get a list of high risky users which are more than 90 days old
$riskyUsers= Get-MgRiskyUser -Filter "RiskLevel eq 'high'" | where RiskLastUpdatedDateTime -LT (Get-Date).AddDays(-90)
# bulk dismiss the risky users
Invoke-MgDismissRiskyUser -UserIds $riskyUsers.Id

后续步骤