Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell Script - Disabled Users w/Mailboxes

Posted on 2013-06-11
7
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 42

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
Industry Leaders: 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 35

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

704 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