?
Solved

List active users in Dynamic Distrubution list

Posted on 2013-06-03
9
Medium Priority
?
444 Views
Last Modified: 2013-06-04
I'm trying to get out a list over all active users that has an active account with mailbox on Exchange 2010. I managed to get a full list, but its over 100 users, so I would like to narrow down the list, to only output those active accounts with an mailbox.

I tried different scripts with Get-DistributionGroupMember and Get-DynamicDistributionGroup, but they only list all users, also those disabled.

Thanks in advance for any help!
0
Comment
Question by:Mr Woober
[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
9 Comments
 
LVL 22

Expert Comment

by:Haresh Nikumbh
ID: 39216383
To remove disabled Active Directory user accounts from all distribution groups in the organization, use the following code:


$groups = Get-DistributionGroup -ResultSize Unlimited

$report = foreach($group in $groups){
 Get-DistributionGroupMember $group |
  ?{$_.RecipientType -like '*User*' -and $_.ResourceType -eq $null} |
   Get-User | ?{$_.UserAccountControl -match 'AccountDisabled'} |
    Select-Object Name,RecipientType,@{n='Group';e={$group}}
}

$report | Export-CSV c:\disabled_group_members.csv -NoType



http://www.packtpub.com/article/exchange-server-2010-windows-powershell-distribution-groups
0
 
LVL 26

Accepted Solution

by:
Leon Fester earned 1500 total points
ID: 39217537
You can use the get-mailbox cmdlet on Exchange Server.
Filters can be applied using the useraccountcontrol variable.

You can try the command:
Get-Mailbox |?{$_.UserAccountControl -Match "normalAccount"}| Fl Name,Database,UserAccountControl

It's a modified query based on:
http://forums.msexchange.org/how_to_use_Exchange_Management_Shell_to_find_disabled_AD_users_with_mailboxes/m_1800563621/tm.htm
AND
http://blogs.bamits.com.au/2011_07_01_archive.html
0
 
LVL 11

Expert Comment

by:Satish Auti
ID: 39218103
Try attached script.....
Gropus.vbs
0
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 1

Author Comment

by:Mr Woober
ID: 39218239
Thanks for the tips, this group is a dynamic group. So I probably need to remove the disabled accounts, does it remove the mailbox aswell? Because I might need to reactivate the user later.
0
 
LVL 26

Assisted Solution

by:Leon Fester
Leon Fester earned 1500 total points
ID: 39218288
erm... if you are using Dynamic groups, then configure your query to exclude disabled accounts.

FYI The query to create the Dynamic groups is run each time that your use the Dynamic groups....so if you exclude disabled accounts in the query you'll never need to maintain the list.

See links below:
http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_23987324.html#a23186983
http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/00aeef18-6528-42a0-9760-118479bf9a7c
http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_25206374.html#a26856470
0
 
LVL 1

Author Comment

by:Mr Woober
ID: 39218338
I manage to solve it :)

Here is what I did:

$list = read-host "Name on group"

Set-DynamicDistributionGroup -Identity "$list" -RecipientFilter {
  (EmailAddresses -like '*hero*') -and
  (HiddenFromAddressListsEnabled -ne $true)
}

$MarketingGroup = Get-DynamicDistributionGroup "$list"
Get-Recipient -RecipientPreviewFilter $MarketingGroup.RecipientFilter -OrganizationalUnit $MarketingGroup.OrganizationalUnit -SortBy Name >> C:\lager\activeusers.txt

Thanks for the help :)
0
 
LVL 1

Author Closing Comment

by:Mr Woober
ID: 39218339
Thanks :)
0
 
LVL 26

Expert Comment

by:Leon Fester
ID: 39218341
OOOO  "C:\lager" what kind of breweries do you work for?
0
 
LVL 1

Author Comment

by:Mr Woober
ID: 39218515
Its norwegian :)
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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 …
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 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