Solved

exchange 2013 powershell

Posted on 2014-09-24
3
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

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 19

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Moving on from sbs 2008... 36 88
Mail Exchanger (MX) Record 5 41
Removing Exchange 2003 3 17
office 365 5 23
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This video discusses moving either the default database or any database to a new volume.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

730 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