May 25 2023 10:09 AM
Hi Team,
I'm trying to pull the users list from just a few
(Not all )Azure AD groups. Is there a way to do in bulk
May 25 2023 11:43 AM
@teja1027 Hi, you can get the result using powershell , here under the script
# Import the Active Directory module
Import-Module ActiveDirectory
# Specify the AD group names
$groupNames = @("Group1", "Group2", "Group3")
# Create an array to store all group members
$allGroupMembers = @()
# Iterate through each group name
foreach ($groupName in $groupNames) {
# Retrieve group members
$groupMembers = Get-ADGroupMember -Identity $groupName | Select-Object Name, SamAccountName
# Add group members to the array
$allGroupMembers += $groupMembers
}
# Export the group members to a CSV file
$csvPath = "C:\Path\to\output.csv"
$allGroupMembers | Export-Csv -Path $csvPath -NoTypeInformation
Write-Host "Export completed. The group members have been saved to: $csvPath"
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily.
May 25 2023 01:51 PM
May 26 2023 01:16 AM
@teja1027 here the script modified to read the groups from csv file
# Import the Active Directory module
Import-Module ActiveDirectory
# Specify the path to the CSV file containing the group names
$csvPath = "C:\Path\to\groups.csv"
# Read the group names from the CSV file
$groupNames = Import-Csv -Path $csvPath | Select-Object -ExpandProperty GroupName
# Create an array to store all group members
$allGroupMembers = @()
# Iterate through each group name
foreach ($groupName in $groupNames) {
# Retrieve group members
$groupMembers = Get-ADGroupMember -Identity $groupName | Select-Object Name, SamAccountName
# Add group members to the array
$allGroupMembers += $groupMembers
}
# Export the group members to a CSV file
$outputCsvPath = "C:\Path\to\output.csv"
$allGroupMembers | Export-Csv -Path $outputCsvPath -NoTypeInformation
Write-Host "Export completed. The group members have been saved to: $outputCsvPath"
May 26 2023 05:33 AM
Refer this, support in csv format: