'Gathering a list of both Standard Attr. and Extended attr. for Azure
I am new to PowerShell and am looking to do something and am not able to figure it out, so naturally I turn to the experts over here. I don't know if it makes a difference, but I will be using Cloud Shell to run this operation.
I am needing to gather a list of all users on my AzureAD environment and collect two pieces of information. The first is a users Display Name or UPN, and the second is an extended attribute (we will call this EA1). After I have that I will need to move it into a CSV so I can send it off.
What I have found so far are two commands that I believe I would need to combine.
Get-AzureADUser | Select displayName
(Get-AzureADUserExtension).get_item("ea1")
Both of those commands will get me the overall information that I am looking for, but I will need to combine/correlate it.
I feel like I will need to set these to variables but I am not 100% sure on this.
Any assistance on this would be much appreciated.
Solution 1:[1]
To reach your requirement, try the below steps if they are helpful:
- To get list of all Azure AD users, make use of below cmdlet:
$AAD_users = Get-AzureADUser -All:$true
- To get the specific properties of all users, make use of foreach loop.
- To expand Extension Attributes related to the user convert Dictionary to Custom Object so that we can use dot (.) operator to access the keys.
- In this, I have retrieved
createdDateTimeextension attribute. You can replace it withEA1 - To Combine both the regular attributes and extension attributes to a single object and to move all the information to a CSV, make use of below script:
$Info = @()
$AAD_users = Get-AzureADUser -All:$true
foreach ($AAD_User in $AAD_users) {
$objInfo = [PSCustomObject]@{
User = $AAD_User.UserPrincipalName
Name = $AAD_User.DisplayName
CreationDate = (Get-AzureADUserExtension -ObjectId $AAD_User.ObjectId).Get_Item("createdDateTime")
}
$Info += $objInfo
}
$Info
Export-csv -Path c:\File.csv -NoTypeInformation -Force -Append
Reference:
Get-AzureADExtension attribute for all AzureAD users
python - How to export Extension Attributes from Azure AD to csv using Powershell - Stack Overflow
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SrideviMachavarapu-MT |


