Posted on 2014-08-21
Last Modified: 2014-11-12
I have Active Directory with the schema extended for Exchange 2013.  I am looking to run a powershell 3.0 script (from my Windows 7 x64 laptop) that will provide me with a report/list of all configured ManagedBy (schema attribute) distribution groups within my Active Directory.  I can view the ManagedBy attribute as a property of the Distribution Group, but I do not have the get-distributiongroup cmdlet on my powershell.  Ideally I'd like to run something similar to below...

"Get-DistributionGroup * | Format-Table Name, ManagedBy"

Do you know of a module I can import to get that cmdlet?  I have the below two PS lines but they need to be joined and search entire directory (if that makes sense).

#This will get me a list of all global distribution groups, displaying only the group name sorting by the name.
"Get-ADGroup -Filter {GroupCategory -eq "Distribution" -and GroupScope -eq "Global"} | Sort-Object | Format-Table Name"

#This will display a specific group and the managedby property.
"Get-ADGroup -Identity <groupname> -Properties ManagedBy"

Question by:jmachado81
    LVL 14

    Expert Comment

    by:Brad Groux
    I believe for security reasons Exchange related PowerShell Cmdlets must be run from the Exchange Management Shell.

    Exchange Management Tools which were utilized in previous versions of Exchange have been replaced by the Exchange Admin Center in Exchange 2013. EAC is now web based and can be accessed via IE at https://<CASServerName>/ecp  internally or externally.

    Author Comment

    Our Exchange environment is hosted in Office365, but that is synced to our AD.  Since Office365 pulls from our AD we should "theoretically" be able to run a script against our internal AD to get that information.

    With that additional information, would we have to do a "connect-msolservice" then?  Again I can see all these settings when I open ADUC.
    LVL 19

    Expert Comment

    by:Adam Farage
    To connect to Office 365 for Exchange using PowerShell, you would need to import a new session into the powershell module:

    You *could* use the Exchange 2013 Exchange Management Shell for this, but you would still have to import a new session. I usually manage my clients O365 from my desktop, since Windows 8.1 comes with PowerShell.

    I think that is where your issue is.

    The same thing goes if you are doing DirSync to Azure AD:
    LVL 38

    Accepted Solution

    Get-ADGroup -Filter {GroupCategory -eq "Distribution" -and GroupScope -eq "Global"}  -Properties ManagedBy | Sort-Object Name | Format-Table Name, ManagedBy

    Open in new window

    This combines the two and displays the Name and ManagedBy info.  Since this information is available in your AD, you don't have to connect to Office365 to get it.

    Author Closing Comment

    That is great footech.  A colleague was able to manipulate that to this, so it doesn't display ones with a null value.

    Get-ADGroup -Filter {GroupCategory -eq "Distribution" -and GroupScope -eq "Global"} -property * | where-object {$_.managedby.length -gt 0}| select name,managedby |Sort-Object -Property name
    LVL 38

    Expert Comment

    If you're concerned at all about the speed with which that runs, change -property * to -property ManagedBy for the Get-ADGroup command.  If you don't have that large a number of groups you may not see a noticeable difference however.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
    Easy CSR creation in Exchange 2007,2010 and 2013
    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…

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now