powershell placing get-content for custom list rather than command

I have a list of distribution lists rather than trying to scan our entire enterprise. Can anyone tell me the best way to implement get-content with a csv for a custom list to be ran against these commands rather than running for a certain group or all groups. thanks


Get-MessageTrackingLog -EventID Expand | ? {$_.RelatedRecipientAddress -like "DG-Marketing@MyDomain.com"} | ft Timestamp,Sender,MessageSubject -Autosize


Get-MessageTrackingLog -Server EXCH1 -EventId Expand -ResultSize Unlimited | Sort-Object RelatedRecipientAddress | Group-Object RelatedRecipientAddress | Sort-Object Name | Select-Object @{label="PrimarySmtpAddress";expression={$_.Name}}, Count
techdriveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
Get-Content is used for text files, while Import-CSV is for .CSV files.  While technically .CSVs are text files, they are formatted in a specific fashion, so it's important to differentiate between a .CSV and plain text file that just has one element per line.

I think you're looking for something like this.
$DGs = Get-Content list.txt
Get-MessageTrackingLog -EventID Expand | ? { $DGs -contains $_.RelatedRecipientAddress } | ft Timestamp,Sender,MessageSubject -Autosize

Open in new window

0
techdriveAuthor Commented:
awesome thanks
0
techdriveAuthor Commented:
hey I am not getting any data when I run this command this way. Its not returning anything and I know some of these groups received email in the last 30 days,
0
ON-DEMAND: 10 Easy Ways to Lose a Password

Learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees in this on-demand webinar. We cover the importance of multi-factor authentication and how these solutions can better protect your business!

footechCommented:
Sorry, but I won't be able to troubleshoot as I don't have access to the right environment.  Maybe I can see an issue if you provide the output from
Get-MessageTrackingLog -EventID Expand | gm
# and maybe
Get-MessageTrackingLog -EventID Expand | ? {$_.RelatedRecipientAddress -like "DG-Marketing@MyDomain.com"}

Open in new window

I need to see what the RelatedRecipientAddress property is like.
0
techdriveAuthor Commented:
still no answer
0
footechCommented:
You haven't provided any more info.
If you want you can click the Request Attention button to try to get some other expert's input.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
techdriveAuthor Commented:
dont worry I was able to resolve
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.