Solved

exchange 2013 powershell

Posted on 2014-09-24
3
249 Views
Last Modified: 2014-09-25
I have this powershell query that finds all distribution or mail enabled security groups  in a OU.  I am dealing with old issues with users who had previous versions of the distribution groups/lists. The problem I found is  I cannot automatically import global security groups into the managedby property. Is there a way to capture if the user field contains a global or universal security group that shows up in the identity field and automatically extract those members to a csv file in the following format.

nameofsecuritygroup        user    nameofdistributiongrouptogointomanagedby
globalsec1                            user1  distlistalaskafolks
globalsec1                            user1  distlistalaskafolks
globalsec2                            user5  distlistchicagofolks


get-distributiongroup -organizationalunit  "OU=marketing,OU=Users,DC=contoso,DC=com" | get-adpermission | where { $_.accessrights -match 'write' -or $_.AccessRights -match 'GenericAll' -and $_.user -notlike '*exchange*' -and $_.user -notlike '*system*' -and $_.user -notlike 's-1*' -and $_.user -notlike '*admins*' -and $_.user -notlike '*organization*' -and $_.user -notlike '*self*' -and $_.user -notlike '*administrators*' } | select identity,user

Open in new window

0
Comment
Question by:techdrive
  • 2
3 Comments
 
LVL 18

Expert Comment

by:Raheman M. Abdul
ID: 40344748
foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft @{expression={$_.displayname};Label=”$group”} | Out-File c:\temp\DistributionListMembers.txt -append}

Open in new window


Does the result of above is ok for you to proceed further?
0
 
LVL 18

Accepted Solution

by:
Raheman M. Abdul earned 500 total points
ID: 40344769
Try this:
$Objects = @()
$groups = Get-DistributionGroup -ResultSize Unlimited 

       $groups | ForEach-Object { 
             [array]$groupMembers = Get-DistributionGroupMember -id $_     
             for ($i = 0; $i -lt $groupMembers.Count; $i++) {
                    $member = $groupMembers[$i].name
                    $object = New-Object System.Object
		            if ($i -eq 0) 
                    {
                       $object | Add-Member -MemberType NoteProperty -Value $_.Name -Name 'Distribution Group' -Force
                    }
                    $object | Add-Member -MemberType NoteProperty -Value $member -Name 'Members' -Force -PassThru                
                    $Objects += $object
             }
       } 
$Objects | Export-Csv -Encoding 'Unicode' c:\temp\GroupMembers.csv

Open in new window

0
 

Author Comment

by:techdrive
ID: 40344821
sweet thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this video we show how to create a Distribution Group in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >>…
how to add IIS SMTP to handle application/Scanner relays into office 365.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now