Use csv to get all DLs a contact is a member of

I have a csv of contacts and I need to get a list of all DLs they are a member of. I have the following script which does it for one contact, but I can't figure out how to use the csv to get all contact DL membership.

$mct=Get-MailContact "user id details"
$Filter="Members -like ""$dn"""
Get-DistributionGroup -ResultSize unlimited -Filter $filter | select Displayname, primarysmtpaddress

No Data
  • Just us a use the Import-Csv cmdlet to read in the file and use a ForLoop to hit each use in the file.
    This is PowerShell 101 thing and well documented in the PowerShell help file and all over the web.
    Just search for 'PowerShell, csv file, forloop'
    For example that search sting swill returns stuff like ...

    Yet, gain, you can get this by reading the help files as well.

    # get function / cmdlet details
    Get-Command -Name Import-Csv -Syntax
    (Get-Command -Name Import-Csv).Parameters.Keys
    Get-help -Name Import-Csv -Full
    Get-help -Name Import-Csv -Online
    Get-help -Name Import-Csv -Examples

    # All Help topics and locations
    Get-Help about_* | Out-GridView -PassThru
    Get-Help about_ForEach
    Get-Help about_Functions | Out-GridView -PassThru

    Get-Help about* | Select Name, Synopsis

    Get-Help about* |
    Select-Object -Property Name, Synopsis |
    Out-GridView -Title 'Select Topic' -OutputMode Multiple |
    ForEach-Object { Get-Help -Name $_.Name -ShowWindow }

    explorer "$pshome\$($Host.CurrentCulture.Name)"

No Data