Export All AzureAD users with an employeeid and\or member of group

Hi, I have to export a list of all AzureAD users where the EmployeeID attribute is not empty, I would also like to confirm if they are also a member of 2 groups. I have the EmployeeID query, just wondering how I can include if they are a members of 2 groups in the same spreadsheet. I can export both groups and get the information in Excel but would prefer to run a powershell script if it’s not a lot of work.

Get-AzureADUser -All: $true | select UserPrincipalName,Displayname, @{Name = 'EmployeeId'; Expression = {$_.ExtensionProperty.employeeId}} | Export-Csv c:\temp\employeeId.csv -NoTypeInformation

Any help appreciated.

Thanks

Gilbert,
Welcome to the forum. :wave:t4:

I cannot test at the moment but that should be an easy task. Simply Query both groups, save the output of each query in a variable and use a Where-Object for your Get-AzureADUser query to determine if - first: the AzureADUser has an EmployeeId AND - second: is found in both groups. :wink:

BTW: When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink: