azure 通过Powershell设置StrongAuthenticationMethods的默认值

ttp71kqs  于 2022-12-04  发布在  Shell
关注(0)|答案(1)|浏览(149)

我正在使用以下脚本为Azure Active Directory中的用户启用MFA方法(片段取自this article):

Connect-MsolService 
$UserPrincipalName = "j.brown@exchangelabs.nl"
$SMS = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationMethod
$SMS.IsDefault = $true
$SMS.MethodType = "OneWaySMS"
$Phone = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationMethod
$Phone.IsDefault = $false
$Phone.MethodType = "TwoWayVoiceMobile"
$PrePopulate = @($SMS, $Phone)
Set-MsolUser -UserPrincipalName $UserPrincipalName -StrongAuthenticationMethods $PrePopulate

它运行得很好,但这意味着我必须在创建新用户时运行它。
是否有办法将其设置为新用户的默认值?
编辑:这里有一个以前的问题,可能会提供一些更多的了解这个问题:
Enforcing phone number in azure active directory MFA

w41d8nur

w41d8nur1#

您是否尝试过下面的代码片段,

Connect-MsolService 
$UserPrincipalName = "email@email.com"
$SMS = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationMethod
$SMS.IsDefault = $true
$SMS.MethodType = "OneWaySMS"
$Phone = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationMethod
$Phone.IsDefault = $false
$Phone.MethodType = "TwoWayVoiceMobile"
$PrePopulate = @($SMS, $Phone)
Get-MsolUser -All  | foreach{set-msoluser -UserPrincipalName $_.UserPrincipalName -StrongAuthenticationMethods $PrePopulate}

相关问题