Solved

Exchange Query

Posted on 2011-02-15
5
1,742 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 38

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 38

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 70

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

757 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

17 Experts available now in Live!

Get 1:1 Help Now