none
Dumping Exchange online mailbox contents RRS feed

  • Question

  • Hi,

    I need to work on 2 programming tasks related to exchange online mailboxes. 

    1. To show list of mailboxes using either Remote PowerShell  or may be EWS.

    2. Dump the contents of an exchange onine mailbox to a local .pst file

    I m talking about Exchange Online (not Office365 which is new form of Exchange online. MS have stopped selling Exchange Online.)

    I know how to use EWS with exchange online (read this article too http://msdn.microsoft.com/en-us/library/gg591267(v=EXCHG.140).aspx), and also have worked with Remote powerShell, but dont know whether I can complete above mentioned tasks with Exchange online using Remote PS or EWS.

    Any help or link would be highly appreciated.


    Regards, David Johnson
    • Edited by Cyber Friend Monday, December 5, 2011 8:57 PM modify
    Monday, December 5, 2011 1:15 PM

All replies

  • 2. PST and MSG are both Office(Outlook) file formats (eg a msg file is a compond OLE document) so to export a mailbox to a PST file you need to use MAPI either extended Mapi or you could use the OOM or possibly a third party library like Redemption http://www.dimastr.com/redemption/home.htm if you need a level of automation. There is also the PST SDK on codeplex http://pstsdk.codeplex.com/ which may help. The only format that EWS supports for exporting is its own opaque datablob that is supported for reimpoting http://msdn.microsoft.com/en-us/library/ff709523(v=exchg.140).aspx

    1. To show a list of Mailboxes your better of using Remote powershell and Get-Mailbox eg against Office365 the following should work

                    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
                    String AdminUserName = "UserName";
                    String Password = "Password";
    
                    System.Security.SecureString secureString = new System.Security.SecureString();
                    foreach (char c in Password)
                        secureString.AppendChar(c);
                    PSCredential credential = new PSCredential(AdminUserName, secureString);
                    WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("https://ps.outlook.com/PowerShell-LiveID?PSVersion=2.0"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
                    connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
                    connectionInfo.SkipCACheck = true;
                    connectionInfo.SkipCNCheck = true;
    
                    connectionInfo.MaximumConnectionRedirectionCount = 4;
                    Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo);
                     runspace.Open();
                    // Make a Get-Mailbox Request
                    Command grGetMailbox = new Command("Get-Mailbox");
                    grGetMailbox.Parameters.Add("ResultSize", "Unlimited");
                    Pipeline plPileLine = runspace.CreatePipeline();
                    plPileLine.Commands.Add(grGetRecipient);
                    Collection<PSObject> RsResultsresults = plPileLine.Invoke();
                    foreach (PSObject obj in RsResultsresults)
                    {
                          Console.WriteLIne(["DisplayName"].Value.ToString());
                    }
                    plPileLine.Stop();
                    plPileLine.Dispose();
    
    Cheers
    Glen

     

    Tuesday, December 6, 2011 2:35 AM