Connect to Azure AD
Azure AD PowerShell Modunle
You need install MSOnline module only once. In the next time, run to connect to Azure AD PowerShell.
##Connect to MSOnline.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;
Install-PackageProvider -Name NuGet -Force;
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted;
Install-Module -Name MSOnline;
Connect-MsolService;
Enable MFA for single user
$email = read-Host 'Email address need to Enable MFA'
$mf= New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement
$mf.RelyingParty = "*"
$mfa = @($mf)
Set-MsolUser -UserPrincipalName $email -StrongAuthenticationRequirements $mfa
Enable MFA Office 365 for all users
$mf= New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement
$mf.RelyingParty = "*"
$mfa = @($mf)
Get-MsolUser -All | Set-MsolUser -StrongAuthenticationRequirements $mfa
Enable MFA for group of users using CSV file
$mf= New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement
$mf.RelyingParty = "*"
$mfa = @($mf)
Import-CSV 'C:\Temp\Users.csv' | `
foreach {Set-MsolUser -UserPrincipalName $_.UserPrincipalName -StrongAuthenticationRequirements $mfa}
Verify it works
mkdir C:\temp; cd C:\temp;
curl -o C:\temp\Get-MFAReport.ps1 https://filedn.com/lOX1R8Sv7vhpEG9Q77kMbn0/leoguides.com/Microsoft/Scripts/Get-MFAReport.ps1;
.\Get-MFAReport.ps1
5/5 - (1 vote)