Solved

exchange 2013 powershell

Posted on 2014-09-24
3
256 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
powershell $webclient.UploadFileWithUniqueName 6 24
How To Change SMTP Port in Powershell Script 1 31
EXCHANGE SENDER POLICY FRAMWORK 6 17
EXCHANGE, ACTIVE DIRECTORY 1 29
Utilizing an array to gracefully append to a list of EmailAddresses
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
how to add IIS SMTP to handle application/Scanner relays into office 365.

806 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