Forum Discussion

jcasqueiro's avatar
jcasqueiro
Brass Contributor
Oct 13, 2023

How to export list of all users with all the attributes

Hi,

Does anyone have a PS script to export all the tenant users with all their attributes (including extended)?

Thanks/Brgds

joao

 

PS: The Get-All_Students_and_Teachers.ps1 doesn't do the job because I need a list of all the users in the tenant

3 Replies

  • RichardE15's avatar
    RichardE15
    Copper Contributor

    Hi Joao! 👋 To export all tenant users with their attributes, including extended ones, PowerShell is your go-to. For Azure AD, you can use the Get-AzureADUser cmdlet with a loop to fetch extended attributes and export them to a CSV. Alternatively, with Microsoft Graph, the Get-MgUser -All -Property * cmdlet provides a more comprehensive solution. Don’t forget to ensure you have the necessary permissions to access and export user data.

  • rao67's avatar
    rao67
    Copper Contributor

     

    Does anyone have a PowerShell script to export all tenant users with all their attributes (including extended attributes)?

    Thanks/Best regards,
    Joao

    P.S. The Get All Students and script doesn’t work for me because I need a list of all users in the tenant.

  • Paul_Wiegmans's avatar
    Paul_Wiegmans
    Copper Contributor
    It should be possible somewhere along the lines like this:

    Import-Module Microsoft.Graph.Authentication
    Import-Module Microsoft.Graph.Users
    Connect-MgGraph
    $users = Get-MgUser -All -Property AccountEnabled, AdditionalProperties, CompanyName, CreatedDateTime, CreationType,
    Department, DisplayName, EmployeeId, GivenName, Id, JobTitle,
    LastPasswordChangeDateTime, Mail, MailNickname, OfficeLocation, PasswordPolicies,
    PasswordProfile, ProxyAddresses, Surname, UsageLocation, UserPrincipalName, UserType,
    extension_92c806d48fcc4740a5b5166f298e334e_extensionAttribute1,
    extension_92c806d48fcc4740a5b5166f298e334e_extensionAttribute2,
    ProxyAddresses
    $users | Export-Csv -Path $output1 -Delimiter ";" -Encoding UTF8 -NoTypeInformation

Resources