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

x
?
Solved

Powershell Script - Disabled Users w/Mailboxes

Posted on 2013-06-11
7
Medium Priority
?
275 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 2000 total points
ID: 39239290
Get-Mailbox |where {$_.UserAccountControl -Match "AccountDisabled"}| select Name,Database,UserAccountControl | export-csv c:\disbaledMailboxes.csv -notype
0
 
LVL 43

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 36

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

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

Stellar Exchange Toolkit: this 5 in 1 toolkit comes loaded with mega-software tool. Here’s an introduction to tools’ usage and advantages:
Eseutil Hard Recovery is part of exchange tool and ensures Exchange mailbox data recovery when mailbox gets corrupt due to some problem on Exchange server.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

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