Forum Discussion

Marvin Oco's avatar
Marvin Oco
Iron Contributor
Jan 26, 2021
Solved

how to enable azure ad MFA using powershell and UPN list in csv file

how to enable azure ad MFA using powershell and UPN list in csv file?   thanks
  • Marvin Oco's avatar
    Marvin Oco
    Feb 02, 2021

     

    HOW TO ENABLE OFFICE 365 MFA USING POWERSHELL AND CSV FILE

     

    1. CREATE CSV FILE WITH HEADER "UserPrincipalNameā€

     

     

    UserPrincipalName

    user1@contoso.com

    user2@contoso.com

    user3@contoso.com

    user4@contoso.com

    user5@contoso.com

    user6@contoso.com

    user7@contoso.com

    user8@contoso.com

    user9@contoso.com

    user10@contoso.com

     

    2.       Run  script BELOW (change the path and name of your csv file)

     

    Connect-MsolService

     

    $users = Import-Csv C:\Users\csv \enablemfa.csv

     

    foreach ($user in $users)

     

    {

        $st = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement

        $st.RelyingParty = "*"

        $st.State = "Enabled"

        $sta = @($st)

        Set-MsolUser -UserPrincipalName $user.UserPrincipalName -StrongAuthenticationRequirements $sta

    }

     

    Write-Host "DONE RUNNING SCRIPT"

     

    Read-Host -Prompt "Press Enter to exit"

     

Resources