powershell check for one domain query

Hi guys I have a command running and it locates the email address but the only thing is it grabs that email address plus everything. What I would like to do is limit the scope to only one domain in our environment.

for example we have 9 different email domains. Currentl I am using this

get-recipient -resultsize:unlimited | where {$_.emailaddresses -like "*@domain.com*" } | displayname, emailaddresses

I only want one domain.
Who is Participating?
SubsunConnect With a Mentor Commented:
You can try this...
Get-Recipient -resultsize:unlimited | 
 where {$_.emailaddresses -match "@domain.com" } | % {
	$Name = $_.displayname
	$_.emailaddresses | where {$_ -match "@domain.com" } | 
	Select @{N="displayname";E={$Name}},@{N="emailaddresses";E={$_}}
}| Export-Csv C:\report.csv -nti

Open in new window

techdriveAuthor Commented:
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.

All Courses

From novice to tech pro — start learning today.