none
Using Get-mailboxexportrequest command in a application (hosted Ex 2010) RRS feed

  • Question

  • Hello,

    Im still pretty new to coding, so please help me get further with it :)

    im trying to make an application to export all mailboxes(from hosted Exchange 2010) and once this is done the .pst files will be backed up with some offsitebackup software.
    the code for exporting the mailbox is a success, it works great.

    however im trying to add in a check to see if the mailbox is really done exporting or not.
    this somehow doesnt work properly, not getting results.
    This is the code im trying:

                    List<PSObject> StillExporting = new List<PSObject>();
                    while (!allorgsdone)
                    {
                        Console.WriteLine("start to do get-mailboixrequest");
                        Pipeline Checkifdone = runspace.CreatePipeline();
                        Command getmailexport = new Command("Get-MailboxExportRequest");
                        getmailexport.Parameters.Add("MultiTenant");
                        getmailexport.Parameters.Add("Status", "InProgress");
                        Checkifdone.Commands.Add(getmailexport);
                        Console.WriteLine(getmailexport.CommandText);
                        Collection<PSObject> GetCheckResult = Checkifdone.Invoke();
                        foreach (PSObject result in GetCheckResult)
                        {
                            Console.WriteLine("Got a result");
                            StillExporting.Add(result);
                        }
                        Console.WriteLine("list count is: " + StillExporting.Count);
                        if (StillExporting.Count > 0)
                        {
                            foreach (PSObject notdone in StillExporting)
                            {
                                Console.WriteLine(notdone.Properties["Name"].Value.ToString() + " Is not done exporting yet");
                            }
                            Console.WriteLine("Going to sleep for 10minutes");
                            StillExporting.Clear();
                            Thread.Sleep(600000);
                        }
                        else
                        {
                            Console.WriteLine("All Organizations Finished exporting, finishing up.");
                            allorgsdone = true;
                        }
                        Console.Read();
                    }

    Tuesday, October 18, 2011 2:45 PM

All replies