Link to home
Start Free TrialLog in
Avatar of bsbgolf
bsbgolf

asked on

Powershell Script - Disabled Users w/Mailboxes

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
ASKER CERTIFIED SOLUTION
Avatar of bepsoccer1
bepsoccer1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Adam Brown
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
I believe it does in 2007.
Avatar of bsbgolf
bsbgolf

ASKER

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
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

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.