Message Trace for all DL's at once Script advice

i need to apply for the following to Multiple E-mail addresses/DL lists could anyone assist basically what i am trying to acheive is

Message trace, Message tracking for all Distribution Groups

i need to apply for the following to Multiple E-mail addresses/DL lists could anyone assist

$endDate = Get-Date
$startDate = (Get-Date).AddMonths(-6)

$sent = Get-MessageTrackingLog -resultsize unlimited -eventid send -Start $startDate -End $endDate -Sender “distgroup@domainname.com

$received = Get-MessageTrackingLog -resultsize unlimited -eventid receive -Start $startDate -End $endDate -Recipients “distgroup@domainnme.com

$results = $send + $receive
$results | Export-Csv -Path “filepath” -NoTypeInformation

Mark,
Welcome to the forum. :wave:t3:

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you potentially wasting their time.

Thanks

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org 1 <---- Click :point_up_2:t4: :wink:

( !! Sometimes the preformatted text button hides behind the settings gear symbol. :wink: )

What exactly is your question? What have you tried so far?

Thanks and sorry about the above totally new here, basically what i am tryinfg to acheive is to run a message trace on an exported list of all Distribution Groups to see which ones have had mail in/out within the last 6 months.

i have been able to acheive this on a Individual basis by outputting the results from one e-mail at a time but canrt seem to find a way to run it against a CSV containing multiple e-mail adresses.

Really? Running some action against an array of elements is one of the most basic tasks you can have in PowerShell. :man_shrugging:t3:

You import your CSV data with

And then you apply the desired actions inside of a script block of a loop with

Please read the help completely including the examples to learn how to use them.