在 Microsoft Entra 和 PowerShell 中获取 MFA 状态
您不想使用 PowerShell 列出 Microsoft 365/Microsoft Entra MFA 用户状态?相反,您想要使用图形用户界面 (GUI)。不用担心,因为您可以从 Microsoft Entra 管理中心获取所有 MFA 详细信息。在本文中,您将了解如何在 Microsoft Entra 和 PowerShell 中获取 MFA 用户身份验证方法。门户网站。
在 Microsoft 租户中配置 MFA 有两种方法:
- 配置 MFA 与条件访问
- 配置每用户 MFA
我们推荐选项1因为您有更多的控制权和更多的功能需要配置。但它需要 Microsoft Entra ID P1 或 Microsoft Entra ID P2 许可证。因此,如果您买不起这些 Entra ID 版本,请选择免费的选项 2。
在此过程中,请阅读文章防止组织中的 MFA 疲劳攻击并启用所示的设置以提供额外的保护。
重要的:为每个租户启用 MFA,因为它至关重要的。
假设您有 Microsoft Entra ID P1 或 P2 并配置了每用户 MFA,但想要迁移到条件访问 MFA;请阅读文章从每用户 MFA 迁移到条件访问 MFA。
如何在 Microsoft Entra 中获取所有用户的 MFA 状态
按照以下步骤检查哪些用户已在 Microsoft Entra 管理中心注册 MFA:
- 登录到微软 Entra 管理中心
- 扩张身份 > 保护
- 点击认证方式
- 选择用户注册详情
笔记:您需要 Microsoft Entra ID P1 或 P2 许可证才能在 Microsoft Entra 管理中心查看用户注册详细信息。如果没有,请使用使用 PowerShell 将 Microsoft Entra ID 用户导出到 CSV 一文中的脚本。
- 检查以下列以获取 MFA 用户帐户状态:
- 多因素身份验证能力
- 默认多重身份验证方法
- 注册方法
如果您想使用 PowerShell 获得相同的报告怎么办?让我们在下一步中看看。
使用 Microsoft Graph PowerShell 获取用户 MFA 状态
获取所有用户身份验证方法的一个绝佳方法是使用 Microsoft Graph PowerShell。
Get-AuthenticationMethods.ps1 脚本将获取所有用户的默认 MFA 方法和注册的身份验证方法,并将其导出到 CSV 文件。
对于每个用户,它都会收集以下信息:
- ID
- 用户主体名称
- 是管理员
- 默认Mfa方法
- 方法注册
- 是否有能力
- 已注册
- 无密码功能
- 是否有能力
- 是否Sspr启用
- 已注册
- IsSystemPreferredAuthenticationMethodEnabled
- 上次更新日期时间
步骤 1. 准备 Get-AuthenticationMethods PowerShell 脚本
上创建两个文件夹(中:)驾驶:
- 温度
- 脚本
下载 Get-AuthenticationMethods.ps1 PowerShell 脚本并将其放入C:脚本文件夹。该脚本会将 CSV 文件导出到C:温度文件夹。
确保文件未被阻止,以防止运行脚本时出现错误。请阅读文章运行 PowerShell 脚本时出现未数字签名错误来了解更多信息。
另一种选择是将以下代码复制并粘贴到记事本中。给它起个名字获取身份验证方法.ps1并将其放置在C:脚本文件夹。
<#
.SYNOPSIS
Get-AuthenticationMethods.ps1
.DESCRIPTION
Export users authentication methods report from Micrososoft Graph and know which MFA method
is set as default for each user and what MFA methods are registered for each user.
.LINK
www.alitajran.com/get-mfa-status-entra/
.NOTES
Written by: ALI TAJRAN
Website: www.alitajran.com
LinkedIn: linkedin.com/in/alitajran
.CHANGELOG
V1.00, 10/12/2023 - Initial version
V1.10, 11/04/2024 - Added parameters to script
#>
param (
[Parameter(Mandatory = $true)]
[string]$CSVPath,
[string]$GroupId = ""
)
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "AuditLog.Read.All", "Group.Read.All"
try {
# If a GroupId is provided, fetch group members first
if ($GroupId) {
Write-Host "Fetching members for GroupId: $GroupId" -ForegroundColor Cyan
$GroupMembers = Get-MgGroupMember -GroupId $GroupId -All
$GroupMemberIds = $GroupMembers.Id
}
# Fetch user registration detail report from Microsoft Graph
if ($GroupId) {
$Users = Get-MgBetaReportAuthenticationMethodUserRegistrationDetail -All | Where-Object { $GroupMemberIds -contains $_.Id }
}
else {
$Users = Get-MgBetaReportAuthenticationMethodUserRegistrationDetail -All
}
# Create custom PowerShell object and populate it with the desired properties
$Report = foreach ($User in $Users) {
[PSCustomObject]@{
Id = $User.Id
UserPrincipalName = $User.UserPrincipalName
UserDisplayName = $User.UserDisplayName
IsAdmin = $User.IsAdmin
DefaultMfaMethod = $User.DefaultMfaMethod
MethodsRegistered = $User.MethodsRegistered -join ','
IsMfaCapable = $User.IsMfaCapable
IsMfaRegistered = $User.IsMfaRegistered
IsPasswordlessCapable = $User.IsPasswordlessCapable
IsSsprCapable = $User.IsSsprCapable
IsSsprEnabled = $User.IsSsprEnabled
IsSsprRegistered = $User.IsSsprRegistered
IsSystemPreferredAuthenticationMethodEnabled = $User.IsSystemPreferredAuthenticationMethodEnabled
LastUpdatedDateTime = $User.LastUpdatedDateTime
}
}
# Output custom object to GridView
$Report | Out-GridView -Title "Authentication Methods Report"
# Export custom object to CSV file
$Report | Export-Csv -Path $csvPath -NoTypeInformation -Encoding utf8
Write-Host "Script completed. Report exported successfully to $csvPath" -ForegroundColor Green
}
catch {
# Catch errors
Write-Host "An error occurred: $_" -ForegroundColor Red
}
步骤 2. 安装 Microsoft Graph PowerShell
以管理员身份运行 Windows PowerShell 并安装 Microsoft Graph PowerShell。
Install-Module Microsoft.Graph -Force
Install-Module Microsoft.Graph.Beta -AllowClobber -Force
重要的:始终安装 Microsoft Graph PowerShell 和 Microsoft Graph Beta PowerShell 模块。这是因为某些 cmdlet 在最终版本中尚不可用,并且它们将无法工作。在运行 cmdlet 或脚本之前将两个模块更新到最新版本,以防止出现错误和不正确的结果。
步骤 3. 连接到 Microsoft Graph PowerShell
连接到 Microsoft Graph PowerShell。
Connect-MgGraph -Scopes "AuditLog.Read.All", "Group.Read.All"
输入您的全局管理员凭据并接受 Microsoft Graph 权限请求。
步骤 4. 运行 Get-AuthenticationMethods PowerShell 脚本
使用 PowerShell 获取所有用户身份验证方法。
C:scripts.Get-AuthenticationMethods.ps1 -CSVPath "C:TempAuthenticationReport.csv"
使用 PowerShell 从组中获取所有用户身份验证方法。在后面添加组的唯一标识符-组ID下面命令中的参数。
C:scripts.Get-AuthenticationMethods.ps1 -CSVPath "C:TempAuthenticationReport.csv" -GroupId "5859108f-0a92-4db3-b779-b9e9f098d4c8"
一个网格视图将显示包含所有用户及其信息的列。
参见:使用 PowerShell 从 CSV 创建 Microsoft Entra ID 用户
步骤 5. 打开身份验证方法报告
Get-AuthenticationMethods.ps1 PowerShell 脚本将所有用户身份验证方法导出到 CSV 文件。找到文件身份验证报告.csv在路径中C:温度。
使用您喜欢的应用程序打开 CSV 文件。在我们的示例中,它是 Microsoft Excel。
就是这样!
多重身份验证常见问题解答
会有关于什么时候状态的问题有能力的和没有能力出现在列表中的用户帐户。以下是您可能有的主要问题及其答案。
有能力和没有能力有什么区别?
- 有能力的:为用户帐户设置MFA
- 没有能力:未为用户帐户设置 MFA
多重身份验证何时显示为“可用”?
它将显示为有能力的如果用户完成 MFA 向导配置。因此只要用户没有完成MFA设置,就会显示为没有能力。
如果您为用户启用或强制执行每用户 MFA,并且用户未配置 MFA,则它仍显示为“无法使用”。如果您配置 MFA 条件访问并将用户添加到策略中,这同样适用。如果用户没有配置MFA,则显示为没有能力。
每用户 MFA 和条件访问 MFA 是否出现在列表中?
是的,每用户 MFA 和条件访问 MFA 用户及其身份验证方法将显示在列表中。
重要的:使用条件访问启用 MFA 时,为所有用户禁用每用户 MFA。
笔记:对于显示为的用户帐户没有能力,联系用户并提醒他们完成 MFA 设置向导。
结论
您了解了如何在 Microsoft Entra 和 PowerShell 中获得 MFA 状态。 Microsoft Entra 管理中心中的身份验证方法部分非常棒。这有助于希望避免使用 PowerShell 获取 MFA 状态信息的管理员。
每个用户都必须配置多重身份验证,通过查看身份验证方法中的用户注册详细信息,您可以快速识别使用了哪些 MFA 方法以及哪些人还需要配置 MFA。
您喜欢这篇文章吗?您可能还喜欢条件访问 MFA 中断 Azure AD Connect 同步。不要忘记关注我们并分享这篇文章。
