locked
Get list of User Mailboxes in Exchange server 2013 by using EWS managed API RRS feed

  • Question

  • Hi all,

    I need list of Users exists in my Exchange server 2013 , i.e Mail Box Users log in name.

    i know the command in Powershell  to get list, but i need this using code[ ews managed API].


    How can i achieve this ?

    Please share your ideas

    Monday, June 9, 2014 7:42 AM

Answers

  • You have made a mistake with the Cmdlet name you have used

    Get-Users

    The cmdlets's Name is

    Get-User

    Cheers
    Glen

    • Marked as answer by Dora407 Monday, June 23, 2014 5:41 AM
    Thursday, June 12, 2014 5:19 AM

All replies

  • Please run below given command in EMS to find all users mailbox name and export into csv:

    Get-Mailbox -ResultSize Unlimited | Select Name,Alias,RecipientTypeDetails | Export-Csv c:\Users.csv


    Carlo

    Monday, June 9, 2014 10:11 AM
  • You can also try this cmdlet below for getting all the mailbox users in your Exchange server .

    Get-Mailbox -ResultSize Unlimited | Select Name,Alias >c:\result.txt

    • Edited by JamesRL Monday, June 9, 2014 10:24 AM
    Monday, June 9, 2014 10:23 AM
  • hi Carlo chapline,

    I need users list  using EWS Managed API code , i.e in C# code . 

    Monday, June 9, 2014 11:01 AM
  • hi Carlo chapline,

    I need users list  using EWS Managed API code , i.e in C# code . 

    Monday, June 9, 2014 11:02 AM
  • EWS is a Mailbox access API so it will only return Address book information about a user so it won't return Users Login Name. The Address book operations like FindPeople, ResolveName will return the DisplayName, EmailAddress and Alias in 2013 you can get the AD Guid but not the loginname. In EWS there should not be any need for the Login name as you should use the PrimarySMTPAddress in any EWS requests.

    A few methods for getting all the Mailboxes would be GetSearchAbleMailboxes http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.exchangeservice.getsearchablemailboxes(v=exchg.80).aspx and also FindPeople using the Address List GUID http://social.technet.microsoft.com/Forums/exchange/en-US/1f26fadc-6fd4-4685-a548-7cf1a3c23d24/get-users-from-global-address-list-gal-using-findpeople-operation-of-office-365?forum=exchangesvrdevelopment

    Cheers
    Glen

     
    Tuesday, June 10, 2014 5:19 AM
    • Edited by Dora407 Tuesday, June 10, 2014 9:11 AM
    Tuesday, June 10, 2014 9:09 AM
  • If you want run Exchange Management Shell cmdlets from managed code then don't load the snapin (you only needed to do this on Exchange 2007). In 2010 and 2013 you can use Remote powershell see http://msdn.microsoft.com/en-us/library/office/ff326159(v=exchg.150).aspx and http://blogs.technet.com/b/exchange/archive/2009/11/02/3408653.aspx

    Cheers
    Glen

    Wednesday, June 11, 2014 5:46 AM
  • Hi Glen,

    I tried with remote PowerShell, but here i am getting Particular user results instead of list.

    please see code

    SecureString secureString = new SecureString();
    string myPassword = "EIS2014!@#"; string username = "ExchangeAdmin@admin.com";
    foreach (char c in myPassword)
    secureString.AppendChar(c);
    PSCredential ExchangeCredentials = new PSCredential(username, secureString);
    WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("http://ExchangeServer.admin.com/powershell ), "http://schemas.microsoft.com/powershell/Microsoft.Exchange , ExchangeCredentials);
    Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo);
    runspace.Open();
    string newCommand = "Get-Mailbox | Get-MailboxPermission";
    Pipeline cmd = runspace.CreatePipeline(newCommand);
    Collection<PSObject> results = cmd.Invoke();
    runspace.Close();

    Wednesday, June 11, 2014 5:57 AM
  • Hi Glen,

    i follow your suggested links i wrote below code ,

    here i am getting error  

    The term 'Get-Users' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

              SecureString password = new SecureString();
                string str_password = "EIS2014!@#";
                string username = "Administrator@admin.com";
                foreach (char x in str_password) { password.AppendChar(x); }
                PSCredential credential = new PSCredential(username, password);
    
                WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("http://ExchangeServer.admin.com/powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
    
                //connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
    
                Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo);
    
                PowerShell powershell = PowerShell.Create();
    
                PSCommand command = new PSCommand();
    
                command.AddCommand("Get-Users");
                command.AddParameter("ResultSize", 50);
                powershell.Commands = command;
    
                runspace.Open();
                powershell.Runspace = runspace;
                var aa =  powershell.Invoke();
    Please help me.

    Wednesday, June 11, 2014 7:22 AM
  • You have made a mistake with the Cmdlet name you have used

    Get-Users

    The cmdlets's Name is

    Get-User

    Cheers
    Glen

    • Marked as answer by Dora407 Monday, June 23, 2014 5:41 AM
    Thursday, June 12, 2014 5:19 AM