Solved

List active users in Dynamic Distrubution list

Posted on 2013-06-03
9
438 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
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 5

Expert Comment

by:Satish Auti
ID: 39218103
Try attached script.....
Gropus.vbs
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Are your AD admin tools letting you down?

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.

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This article runs through the process of deploying a single EXE application selectively to a group of user.
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

785 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