The following script returns users that exist in 2 Active Directory groups

# Import the Active Directory module if it's not already loaded
if (-not (Get-Module -Name ActiveDirectory)) {
    Import-Module ActiveDirectory
}

# Specify the names of the two Active Directory groups
$groupName1 = "YourGroupName1"
$groupName2 = "YourGroupName2"

# Get the members of the two groups
$group1Members = Get-ADGroupMember -Identity $groupName1 -Recursive | Where-Object {$_.objectClass -eq "user"} | Select-Object -ExpandProperty SamAccountName
$group2Members = Get-ADGroupMember -Identity $groupName2 -Recursive | Where-Object {$_.objectClass -eq "user"} | Select-Object -ExpandProperty SamAccountName

# Find the users that exist in both groups
$commonMembers = $group1Members | Where-Object { $group2Members -contains $_ }

# Get the DistinguishedName and EmailAddress of each user, sort the users and return the list
foreach ($user in $commonMembers) {
    $userInfo = Get-ADUser -Identity $user -Properties DistinguishedName, EmailAddress | Select-Object SamAccountName, DistinguishedName, EmailAddress
    $userInfo
} | Sort-Object SamAccountName

By Rudy