Solved

List active users in Dynamic Distrubution list

Posted on 2013-06-03
9
439 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 6

Expert Comment

by:Satish Auti
ID: 39218103
Try attached script.....
Gropus.vbs
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

856 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