Solved

Exchange Query

Posted on 2011-02-15
5
1,836 Views
Last Modified: 2012-06-27
Hi,

I need an exchange script that will give me the all users in which their email is NOT being forwarded, as well as users who are being Stored and Forwarded
0
Comment
Question by:Methodman85
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Adam Brown earned 250 total points
ID: 34899226
This should do it and output the results to a couple CSV files. It will include some system mailboxes as well, though.
get-mailbox | where {$_.forwardingaddress -like $null} | select primarysmtpaddress,samaccountname,displayname | export-csv C:\noforward.csv
get-mailbox | where {$_.delivertomailboxandforward -notlike $false} | select primarysmtpaddress,samaccountname,displayname,forwardingaddress | export-csv C:\storeandforward.csv

Open in new window

0
 
LVL 1

Author Comment

by:Methodman85
ID: 34899650
awesome thank you!
one more thing, I tried to add the users department in the mix, but the field is blank on the CSV file, perhaps I have the wrong name for the department attribute.
0
 
LVL 40

Expert Comment

by:Adam Brown
ID: 34899711
The department attribute isn't returned by the get-mailbox command, unfortunately. It gets more complex when you want to pull attributes not returned by the get-mailbox cmdlet.
0
 
LVL 71

Assisted Solution

by:Chris Dent
Chris Dent earned 250 total points
ID: 34899741
More complex is right. It'd go like this:
Get-Mailbox -Filter { ForwardingAddress -eq $Null } | Select-Object PrimarySmtpAddress, 
    SamAccountName, DisplayName,
    @{n='Department';e={ (Get-User $_.DistinguishedName).Department }} | 
  Export-Csv C:\noforward.csv -NoTypeInformation

Open in new window

Subject to testing, because I haven't done that.

Chris
0
 
LVL 1

Author Closing Comment

by:Methodman85
ID: 34901666
Thank you both!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

A hard and fast method for reducing Active Directory Administrators members.
After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

751 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