Summary
This script will export user profiles to csv. Users can be exported from a list of users.
Pre-requisites
CLI for Microsoft https://aka.ms/cli-m365
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
m365 login --authType deviceCode
# Get all users and their properties, add properties as needed with --properties and separate with comma
m365 aad user list --properties "displayName,mail"
# Get all users and their properties and export to csv
m365 aad user list --output csv --properties "displayName,mail,givenName,jobTitle,mail,mobilePhone,officeLocation,preferredLanguage,surname,userPrincipalName,id" > users.csv
# Get current user with all properties
m365 aad user get --id "@meId"
# get any user with all properties
m365 aad user get --id "UserID"