Solved

exchange 2013 powershell

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
In this video we show how to create a Shared Mailbox 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 >> Sha…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

896 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

16 Experts available now in Live!

Get 1:1 Help Now