Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Exchange Query

Posted on 2011-02-15
5
Medium Priority
?
1,977 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
  • 2
  • 2
5 Comments
 
LVL 43

Accepted Solution

by:
Adam Brown earned 1000 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 43

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 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to effectively resolve the number one email related issue received by helpdesks.
Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

916 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