Powershell CustomSecurityAttributes

Gerhard De Villiers-Mohr 1 Reputation point
2022-03-03T22:40:37.353+00:00

Hi

I am looking for a way to retrieve all users from Azure AD with a "Custom Security Attribute" that matches a value and then return only the users assigned to that specific value and output to Excel or CSV using PowerShell.

Or better yet.
Output all users with Custom Security Attributes with all Values to Excel. Then I can filter within excel.

ie: Attribute Set = Product
Attribute Name = Product Name
Value = Shoe Size

I can filter it in Azure Portal but looking to do this via Powershell.

Any help will be appreciated.

I am halfway there or maybe just a smidge.
Get-AzureADMSUser -Id xxxx.xxxx.xxxxx.xxxxx -Select CustomSecurityAttributes

The above only outputs the Attribute set only linked to specific user. Hence I am looking to do all users but also output the Value not just the Attribute set.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Carlos Solís Salazar 18,191 Reputation points MVP Volunteer Moderator
    2022-03-05T14:25:25.567+00:00

    Hi @Gerhard De Villiers-Mohr

    You can use the Module AzureAD

    Install-Module AzureAD # As Admin  
    

    And the connect to AzureAD

    Connect-AzureAD  
    

    After that you can select various attributes, Ex:

    Get-AzureADUser | select UserPrincipalName,usertype  
    

    In this example, the command retrieves the UPN and the user type. You can choose any attribute that you requiere.

    Hope this helps,
    Carlos Solís Salazar

    ----------

    Please "Accept as Answer" and Upvote if any of the above helped so that, it can help others in the community looking for remediation for similar issues.

    1 person found this answer helpful.
    0 comments No comments

  2. Siva-kumar-selvaraj 15,721 Reputation points
    2022-04-04T06:23:34.257+00:00

    Hi @Gerhard De Villiers-Mohr ,

    Thanks for reaching out.

    You may need to use -All $true along with Get-AzureADUser cmdlet as shown below, otherwise the cmdlet will return just the top 100 users. Hope this helps.

    Get-AzureADUser -All $true | select UserPrincipalName, CustomSecurityAttributes

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.