Link to home
Start Free TrialLog in
Avatar of detox1978
detox1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Export Azure AD User Data

Hi All,


I'd like to review the mobile numbers everyone has registered for their MFA.


Any idea how i can get this without having to click into each user one at a time.


Many thanks

D

Avatar of lcohan
lcohan
Flag of Canada image

I believe you can do that via O365 reports as described here https://o365reports.com/2019/05/09/export-office-365-users-mfa-status-csv/ where "MFA phone" column gives you what you need. Just download and run GetMFAStatus.ps1 powershell script from the above link.
Avatar of dfke
dfke

Hi,

something like:

Import-Module AzureAD
Connect-AzureAD

try {
  $users = Get-AzureADUser | Select-Object -ExpandProperty SignInNumbers
  if (!$users) {
    throw "No users found in the directory."
  }

  $result = @()
  foreach ($user in $users) {
    try {
      $upn = $user.Value
      $mobile = (Get-AzureADUser -ObjectId $upn).Mobile
      if (!$mobile) {
        throw "Mobile number not found for user $upn."
      }
      $result += New-Object PSObject -Property @{
        UserPrincipalName = $upn
        Mobile = $mobile
      }
    } catch {
      Write-Error "Error retrieving mobile number for user $upn: $_"
    }
  }

  if (!$result) {
    throw "No mobile numbers were found."
  }

  $result | Select-Object UserPrincipalName, Mobile | Export-Csv -Path "MFA_MobileNumbers.csv" -NoTypeInformation
  Write-Host "Successfully exported mobile numbers to MFA_MobileNumbers.csv."
} catch {
  Write-Error "Error retrieving mobile numbers: $_"
}

Open in new window



Cheers
ASKER CERTIFIED SOLUTION
Avatar of FOX
FOX
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial