Exchange 2007 Mailbox Listing by OU

Here we go again … PowerShell for a GUI OS.

Today was one of those – we need this list of user names and email addresses but don’t include this set of users and this other set of users. Simple Right? Well, not so much because the users don’t have Departments specified in the account, and the OU structure looks like this:

Domain > AllStaff> Location > Users

So, here’s how I got this list:

Get-Mailbox -resultsize unlimited -OrganizationalUnit “AllStaff” | where {-not ($_.organizationalunit -eq “Domain/AllStaff/Location/Users”) -and -not ($_.organizationalunit -eq “Domain/AllStaff/Other_Location/Users”) } | select displayname,primarysmtpaddress |Export-CSV c:\temp\List.CSV

Handy No?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s