Solved

Powershell Script - Disabled Users w/Mailboxes

Posted on 2013-06-11
7
84 Views
Last Modified: 2015-06-23
Does anyone have a simple way to create a powershell or other type of script to generate list (export to .CSV) that will list all disabled users with mailboxes?  

This is an Win2008 domain using Exchange 2007.

Thanks,
Bg
0
Comment
Question by:bsbgolf
7 Comments
 
LVL 4

Accepted Solution

by:
bepsoccer1 earned 500 total points
ID: 39239290
Get-Mailbox |where {$_.UserAccountControl -Match "AccountDisabled"}| select Name,Database,UserAccountControl | export-csv c:\disbaledMailboxes.csv -notype
0
 
LVL 38

Expert Comment

by:Adam Brown
ID: 39239383
bepsoccer1, that won't work. UserAccountControl doesn't get returned by get-mailbox. One way you can do this is to use the quest powershell cmdlets (Now owned by dell, just google quest powershell) and running
get-aduser -disabled -includedproperties msexchaddressbookflags| where {$_.msexchaddressbookflags -notlike $null} | select samaccountname | export-csv c:\file.csv
0
 
LVL 4

Expert Comment

by:bepsoccer1
ID: 39239407
I believe it does in 2007.
0
 

Author Comment

by:bsbgolf
ID: 39245327
bepsoccer1,

You script did work.  Can I add the default email SMTP address and show if the mailbox is being forwarded to another mailbox to that query as well?  That would help designate if we have already moved the default to another user or forwarded all email?

Thanks,
Bg
0
 
LVL 4

Expert Comment

by:bepsoccer1
ID: 39245891
You can change your where to
{$_.UserAccountControl -Match "AccountDisabled" -and $_.ForwardingAddress -eq $null}

Open in new window

if you want to filter out mailboxes that have been forwarded.  And to show the primary email addres you can add
select Name,Database,UserAccountControl,PrimarySmtpAddress

Open in new window

to the line.

So the final may look something like this.
Get-Mailbox | where {$_.UserAccountControl -Match "AccountDisabled" -and $_.ForwardingAddress -eq $null}| select Name,Database,UserAccountControl,PrimarySmtpAddress | export-csv c:\disbaledMailboxes.csv -notype

Open in new window

0
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 40845707
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

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.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
how to add IIS SMTP to handle application/Scanner relays into office 365.

746 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

18 Experts available now in Live!

Get 1:1 Help Now