Solved

List active users in Dynamic Distrubution list

Posted on 2013-06-03
9
441 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 500 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 7

Expert Comment

by:Satish Auti
ID: 39218103
Try attached script.....
Gropus.vbs
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

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…
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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