Hi @Roger Roger
What about checking this:
$names= Import-Csv C:\test\data.csv
$Result= @()
foreach($name in $names){
$groups= Get-UnifiedGroup -ResultSize Unlimited
foreach($UnifiedGroup in $groups){
foreach($member in (Get-UnifiedGroupLinks -Resultsize Unlimited $UnifiedGroup.name -LinkType Members)){
if ($member.PrimarySMTPaddress -eq $name.User_Principal_Name){
$Result1 = New-Object PSObject
$Result1 | Add-Member NoteProperty -Name "User" -Value $name.User_Principal_Name
$Result1 | Add-Member NoteProperty -Name "UnifiedGroup" -Value (Get-UnifiedGroup -Resultsize Unlimited $UnifiedGroup.name).PrimarySMTPaddress
$Result += $Result1
}
}
}
}
$Result | Export-csv -Path C:\test\output.csv -NoTypeInformation
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.