Solved

Exchange Query

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

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 39

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

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

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

820 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