Created
May 12, 2020 13:05
-
-
Save watahani/c3ca032a408a016e90192a4e58506901 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# すべてのユーザーに一括して会社電話番号での MFA を設定する | |
Get-MsolUser -All | ForEach { | |
$user = $_ | |
$mfa = $user.StrongAuthenticationMethod | |
# MFA が何も設定されていない | |
if (-not $mfa) { | |
$twoWayOfficeDefaultTrue = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationMethod | |
$twoWayOfficeDefaultTrue.MethodType = "TwoWayVoiceOffice" | |
$twoWayOfficeDefaultTrue.IsDefault = $True | |
$mfa = @($twoWayOfficeDefaultTrue) | |
} | |
else { | |
# MFA が設定されていて | |
# かつ、TwoWayVoiceOffice が設定されていない場合 | |
if ( -not ($($mfa | Where-Object { $_.MethodType -eq "TwoWayVoiceOffice" })) ) { | |
$twoWayOffice = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationMethod | |
$twoWayOffice.MethodType = "TwoWayVoiceOffice" | |
$twoWayOffice.IsDefault = $False | |
$mfa += $twoWayOffice | |
} | |
} | |
$mfa | |
Set-MsolUser -UserPrincipalName $_.UserPrincipalName -StrongAuthenticationMethods $mfa | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment