Prepopulating MFA phone authentication (Multi-Factor Authentication) details on a user in Azure Active Directory means getting a known second factor added to a user's account details automatically. These details are also known as the user's "Strong Authentication Methods."
Normally MFA enrollment is a manual process done with the Microsoft Authenticator App during first sign-in. However, a more basic second factor, the user's cellular/mobile number, is usually known to IT in a corporate environment.
With a recent addition to the Microsoft Graph API, it is now possible to add or replace a user's strong authentication phone method programmatically. This enables you to register users automatically for MFA and SSPR at the same time.
>> The MFA Automation Solution
The solution uses the following Microsoft technologies:
* Azure Automation
* Microsoft Graph API (beta)
* PowerShell
* Azure AD (P1)
* Combined registration
* (Optionally) Azure Log Analytics
* An Azure Subscription
>> Required permissions
The solution requires delegated permissions with one of these roles:
* Global admin
* Privileged authentication admin
* Authentication admin
>> Use cases
* Have users registered for MFA and SSPR as part of account provisioning
* Lock down MFA registration completely
* Get to compliant Multi-Factor Authentication state in record time
* Have SSPR work from the user's first day
* Register users that never seem to get caught by registration prompts
>> Installation
>> Creating the Automation Account
Create a new Automation Account with a RunAs account. Configure the subscription, resource group, location, and leave "Create Azure Run As account" on "Yes".
>> Adding API permissions to the Service Principal
>> Delegated permissions
* USERAUTHENTICATIONMETHOD.READWRITE.ALL
>> Application permissions
* USER.READ.ALL
* REPORTS.READ.ALL
* GROUPMEMBER.READ.ALL
>> Default client type
Set the App registration to treat the application as a public client under AUTHENTICATION > DEFAULT CLIENT TYPE > YES.
>> Creating the service account
Assign the AUTHENTICATION ADMINISTRATOR role:
If using PIM, assign as ACTIVE and PERMANENTLY ASSIGNED: