Solved

powershell check for one domain query

Posted on 2013-12-23
2
343 Views
Last Modified: 2013-12-24
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.
0
Comment
Question by:techdrive
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39737446
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

0
 

Author Comment

by:techdrive
ID: 39737778
thanks
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now