Sep 30 2020
10:02 PM
- last edited on
Jan 14 2022
04:29 PM
by
TechCommunityAP
Sep 30 2020
10:02 PM
- last edited on
Jan 14 2022
04:29 PM
by
TechCommunityAP
Hi All,
How to get all users exported from an AD AzureGroup listing their,email addresses e.g a group starting with "HRUSERS"
Do i need to install a module for powershell?
Thanks in advance
Sep 30 2020 11:42 PM
PowerShell is the best way to do this, you'll need the AzureAD or the MSOnline module. Here's a sample for the former:
Get-AzureADGroup -SearchString GroupName | Get-AzureADGroupMember | select DisplayName,UserPrincipalName | Export-Csv -nti blabla.csv
Oct 01 2020 12:14 AM
@VasilMichev Thanks so much for the response.
When i ran the command it worked but how can i add another field showing the actual group name ( e.g something like this
GroupName | DisplayName(This is the name of the user) | UserPrincipleName(Email address)
The searchstring i used is for example is "Test" but there are groups with names Test1,Test 123,Test456
So what i need is something like this :-
GroupName | DisplayName(This is the name of the user) | UserPrincipleName(Email address)
Test1 Peter O po@email
Test123 Michael Dunns md@email
Is this possible?
Thanks in Advance
Oct 01 2020 08:58 AM
That's a bit more complicated, as in it requires a more convoluted piece of code to fit in a single line.
$groups = Get-AzureADGroup -SearchString TeamOne
foreach ($group in $groups) { Get-AzureADGroupMember -ObjectId $group.ObjectId | select @{n="GroupName";e={$group.DisplayName}},DisplayName,UserPrincipalName}
Oct 01 2020 08:19 PM
@VasilMichev Thanks for the reply,
$groups = Get-AzureADGroup -SearchString TeamOne
foreach ($group in $groups) { Get-AzureADGroupMember -ObjectId $group.ObjectId | select @{n="GroupName";e={$group.DisplayName}},DisplayName,UserPrincipalName Export-Csv -nti GetTestGroupMembers.csv
}
I tried adding an export function to it like above but it seems i'm only getting the fist group on the list.
But i can see that you are looping through all the groups.
Am i missing something.
I need it to export all the groups in the list to the csv
Thanks in Advance
Oct 01 2020 11:00 PM
SolutionUse the -Append switch for Export-CSV.
Oct 02 2020 12:44 AM
Oct 01 2020 11:00 PM
SolutionUse the -Append switch for Export-CSV.