Hi,
Assuming you save the scv file in "c:\temp\name.csv", run the following script in powershell:
$names= Import-Csv c:\temp\name.csv
$Result= @()
$groups= Get-DistributionGroup
foreach ($name in $names) {
foreach($group in $groups){
foreach ($member in (Get-DistributionGroupmember $group.name)){
if ($member.PrimarySMTPaddress -eq $name.name){
$Result1 = New-Object PSObject
$Result1 | Add-Member NoteProperty -Name "User" -Value $name.name
$Result1 | Add-Member NoteProperty -Name "group" -Value (Get-distributiongroup $group.name).PrimarySMTPaddress
$Result += $Result1
}}}}
$Result|Export-csv -Path c:\temp\result.csv -NoTypeInformation
It may take some time and the result would be at "c:\temp\result.csv".
Besides, are there any other user types in your csv like mail contact?
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.