Retrieve Distribution Group Members in Office 365 Exchange Online

This script shows how to use the Exchange Web Service Managed API to retrieve group members in distribution groups. Additionally, this script enables you to easily retrieve group members if you have nested distribution groups.

 
 
 
 
 
3.2 Star
(6)
4,555 times
Add to favorites
Office 365
10/18/2013
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Cannot connect to Exchange Online using proposed commands
    2 Posts | Last post February 13, 2017
    • OFFICE365 Connected 17:20 > Connect-OSCEXOWebService -Credential (Get-Credential
       XXXX@@XXX.onmicrosoft.com) -Force -Verbose
      VERBOSE: Establishing connection to Exchange Online by using Exchange Web
      Service Managed API.
      Connect-OSCEXOWebService : Exception calling "AutodiscoverUrl" with "2" argumen
      t(s): "The Autodiscover service couldn't be located."
      At line:1 char:25
      + Connect-OSCEXOWebService <<<<  -Credential (Get-Credential XXXX@XXXX.on
      microsoft.com) -Force -Verbose
          + CategoryInfo          : NotSpecified: (:) [Connect-OSCEXOWebService], Me
         thodInvocationException
          + FullyQualifiedErrorId : DotNetMethodException,Connect-OSCEXOWebService
    • I experienced this error:
      
      Connect-OSCEXOWebService : Exception calling "AutodiscoverUrl" with "2" argument(s): "The Autodiscover service couldn't be located."
      At line:1 char:1
      + Connect-OSCEXOWebService -Credential(Get-Credential exchange.service@ ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Connect-OSCEXOWebService], MethodInvocationException
          + FullyQualifiedErrorId : AutodiscoverLocalException,Connect-OSCEXOWebService
       
      
      It turned out, after some troubleshooting, that the error occurred because I had created a new account, exchange.service, to run the connect-OSCEXOWebService command, but I had the left the
      
       Make this user change their password when they first sign in
      
      box ticked in the account details.
      
      Once I un-ticked this box (and signed into the mailbox to double-check), the command run without error.
      
      
       
      
      
  • Digital Signing. Missing so load bad
    2 Posts | Last post August 14, 2014
    • I will try to work around it but should signing be natural nowadays? Cheers, Richard
      
      import-module : File C:\TRAVELLING\PowerShell\GetOSCEXODistributionGroupMember.psm1 cannot be loaded. The file 
      C:\TRAVELLING\PowerShell\GetOSCEXODistributionGroupMember.psm1 is not digitally signed. You cannot run this script on the current system. For more 
      information about running scripts and setting execution policy, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
      At line:1 char:1
      + import-module .\GetOSCEXODistributionGroupMember.psm1
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
          + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
    • Hello,
      
      Thanks for your feedback. 
      
      We haven’t signed our scripts because they are script samples. It’s possible that you want to tweak these samples in your environment.
      
      Currently, you can change your execution policy to work around this issue.
      
      Best Regards,
      OneScript Team
  • So no answers
    2 Posts | Last post June 28, 2013
    • Looking at the below questions I see they are never responded to. I have the autodiscover issue and Cloudmanners fix does not work for me.  
      
      Can anyone help to get this script working
      
    • Hello,
      
      Sorry for the delay.
      
      Are you using this script in Windows PowerShell V2?  We found an issue in Connect-OSCEXOWebService. The script package has been updated for fixing this issue. Please download the new script package and try again.
      
      Please let us know if you still have problem when using this script.
      
      Best Regards
      Microsoft All-In-One Script Framework
  • AutoDiscover not found
    1 Posts | Last post June 25, 2013
    • How does this work, because no matter what I do it just spits back an error. 
      
      Set-OrganizationConfig -EwsEnabled:$True -EwsAllowOutlook:$none -EwsApplicationAccessPolicy:$none  -EwsAllowList:$none
      
      did nothing to help my Autodiscover service not being located.  
  • Cannot connect to Exchange Online using Connect-OSCEXOWebService -Credential (Get-Credential admin@domain01.onmicrosoft.com) -Verbose
    2 Posts | Last post June 12, 2013
    • With the following error:
      
      Connect-OSCEXOWebService : Exception calling "AutodiscoverUrl" with "2" argumen
      t(s): "The Autodiscover service couldn't be located."
      At line:1 char:25
      + Connect-OSCEXOWebService <<<<  -Credential (Get-Credential leonadmin@tsx.onmi
      crosoft.com) -Verbose
          + CategoryInfo          : NotSpecified: (:) [Connect-OSCEXOWebService], Me
         thodInvocationException
          + FullyQualifiedErrorId : DotNetMethodException,Connect-OSCEXOWebService
      
      What do I miss here?
      
    • Got it, EWS was not configured properly on Organizational level...
      
      
      Set-OrganizationConfig -EwsEnabled:$True -EwsAllowOu
      tlook:$none -EwsApplicationAccessPolicy:$none  -EwsAllowList:$none