Powershell Script - Disabled Users w/Mailboxes

Posted on 2013-06-11
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.

Question by:bsbgolf
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

Accepted Solution

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

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

Expert Comment

ID: 39239407
I believe it does in 2007.
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  


Author Comment

ID: 39245327

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?


Expert Comment

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

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.

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exchange server Error 3 42
Force Updates from WSUS 5 55
Windows 2012 R2 DeDup vs SAN DeDup 6 29
Process to let ex-employee have company laptop 5 25
Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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