Ο365: How to enable MFA using PowerShell and CSV File
The steps below show how we can enable MFA to multiple accounts by using a PowerShell script and a CSV file.
Step 1. Create the CSV File
On the first step we need to create a csv file with the column "UserPrincipalName”
|
Step 2. Run the PowerShell script
The second step is to run the below PowerShell script.
Note: 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"
*** ***