Paging eDiscovery outcomes with the EWS Managed API in Change 2013

Paging eDiscovery outcomes with the EWS Managed API in Change 2013 eDiscovery is likely one of the new options in Change 2013 aimed toward each enhancing the search expertise and in addition serving to take care of Huge Knowledge in a mailbox or mailboxes (which is type of just like the Solar in that its simply retains getting greater and can at some point eat us all).

With eDiscovery in EWS you may carry out two sorts of searches a

  • Estimate Question – Which can return details about the variety of hits for a selected KQL question.
  • Preview Question – Will return your question hits as PreviewItems which you’ll then use to indicate extra details about every hit.

In case your doing a Preview Question with a really generic search predicate that’s going to be returning many preview Gadgets and due to the scale of those outcomes they’ll returned as separate paged outcomes units. This can imply you will have to make a number of search requests to navigate thought the outcome set pages.

To inform the server you need the following Web page within the Outcomes set it’s good to use the PageItemReference  . The PageItemReference worth must be set to the SortValue of the Final Preview-item returned by the earlier web page.

I’ve put collectively a few Managed API samples for this one is a C# instance and the opposite is a Template Powershell script you need to use to do a eDiscovery on one mailbox. These pattern pages gadgets again in plenty of 100, you may regulate this worth however I would not go a lot over 1000.  I’ve put a download of the code right here, the script seems like.

  1. ## Get the Mailbox to Entry from the 1st commandline argument  
  2.   
  3. $MailboxName = $args[0]  
  4. $KQL = “Subject:test”;  
  5. $SearchableMailboxString = $MailboxName;  
  6.   
  7. ## Load Managed API dll    
  8. Add-Kind -Path “C:Program FilesMicrosoftExchangeWeb Services2.0Microsoft.Exchange.WebServices.dll”    
  9.     
  10. ## Set Change Model    
  11. $ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Change2013    
  12.     
  13. ## Create Change Service Object    
  14. $service = New-Object Microsoft.Change.WebServices.Knowledge.ExchangeService($ExchangeVersion)    
  15.     
  16. ## Set Credentials to use two choices are availible Option1 to use explict credentials or Choice 2 use the Default (logged On) credentials    
  17.     
  18. #Credentials Choice 1 utilizing UPN for the home windows Account    
  19. $psCred = Get-Credential    
  20. $creds = New-Object System.Web.NetworkCredential($psCred.UserName.ToString(),$psCred.GetNetworkCredential().password.ToString())    
  21. $service.Credentials = $creds        
  22.     
  23. #Credentials Choice 2    
  24. #service.UseDefaultCredentials = $true    
  25.     
  26. ## Select to ignore any SSL Warning points precipitated by Self Signed Certificates    
  27.     
  28. ## Code From http://poshcode.org/624  
  29. ## Create a compilation surroundings  
  30. $Supplier=New-Object Microsoft.CSharp.CSharpCodeProvider  
  31. $Compiler=$Supplier.CreateCompiler()  
  32. $Params=New-Object System.CodeDom.Compiler.CompilerParameters  
  33. $Params.GenerateExecutable=$False  
  34. $Params.GenerateInMemory=$True  
  35. $Params.IncludeDebugInformation=$False  
  36. $Params.ReferencedAssemblies.Add(“System.DLL”) | Out-Null  
  37.   
  38. $TASource=@ 
  39.   namespace Native.ToolkitExtensions.Web.CertificatePolicy{ 
  40.     public class TrustAll : System.Web.ICertificatePolicy { 
  41.       public TrustAll() {  
  42.       } 
  43.       public bool CheckValidationResult(System.Web.ServicePoint sp, 
  44.         System.Safety.Cryptography.X509Certificates.X509Certificates cert,  
  45.         System.Web.WebRequest req, int downside) { 
  46.         return true; 
  47.       } 
  48.     } 
  49.   } 
  50. @   
  51. $TAResults=$Supplier.CompileAssemblyFromSource($Params,$TASource)  
  52. $TAAssembly=$TAResults.CompiledAssembly  
  53.   
  54. ## We now create an occasion of the TrustAll and connect it to the ServicePointManager  
  55. $TrustAll=$TAAssembly.CreateInstance(“Local.ToolkitExtensions.Net.CertificatePolicy.TrustAll”)  
  56. [System.Net.ServicePointManager]::CertificatePolicy=$TrustAll  
  57.   
  58. ## finish code from http://poshcode.org/624  
  59.     
  60. ## Set the URL of the CAS (Consumer Entry Server) to use two choices are availbe to use Autodiscover to discover the CAS URL or Hardcode the CAS to use    
  61.     
  62. #CAS URL Choice 1 Autodiscover    
  63. $service.AutodiscoverUrl($MailboxName,{$true})    
  64. “Using CAS Server : “ + $Service.url     
  65.      
  66. #CAS URL Choice 2 Hardcoded    
  67.     
  68. #$uri=[system.URI] “https://casservername/ews/exchange.asmx”    
  69. #$service.Url = $uri      
  70.     
  71. ## Elective part for Change Impersonation    
  72.     
  73. #$service.ImpersonatedUserId = new-object Microsoft.Change.WebServices.Knowledge.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $MailboxName)   
  74.   
  75.   
  76. $gsMBResponse = $service.GetSearchableMailboxes($SearchableMailboxString$false);  
  77. $gsMBResponse  
  78. $msbScope = New-Object  Microsoft.Change.WebServices.Knowledge.MailboxSearchScope[] $gsMBResponse.SearchableMailboxes.Size  
  79. $mbCount = 0;  
  80. foreach ($sbMailbox in $gsMBResponse.SearchableMailboxes)  
  81. {  
  82.     $msbScope[$mbCount] = New-Object Microsoft.Change.WebServices.Knowledge.MailboxSearchScope($sbMailbox.ReferenceId, [Microsoft.Exchange.WebServices.Data.MailboxSearchLocation]::All);  
  83.     $mbCount++;  
  84. }  
  85. $smSearchMailbox = New-Object Microsoft.Change.WebServices.Knowledge.SearchMailboxesParameters  
  86. $mbq =  New-Object Microsoft.Change.WebServices.Knowledge.MailboxQuery($KQL$msbScope);  
  87. $mbqa = New-Object Microsoft.Change.WebServices.Knowledge.MailboxQuery[] 1  
  88. $mbqa[0] = $mbq  
  89. $smSearchMailbox.SearchQueries = $mbqa;  
  90. $smSearchMailbox.PageSize = 100;  
  91. $smSearchMailbox.PageDirection = [Microsoft.Exchange.WebServices.Data.SearchPageDirection]::Subsequent;  
  92. $smSearchMailbox.PerformDeduplication = $false;             
  93. $smSearchMailbox.ResultType = [Microsoft.Exchange.WebServices.Data.SearchResultType]::PreviewOnly;  
  94. $srCol = $service.SearchMailboxes($smSearchMailbox);  
  95.   
  96. if ($srCol[0].Outcome -eq [Microsoft.Exchange.WebServices.Data.ServiceResult]::Success)  
  97. {  
  98.     if ($srCol[0].SearchResult.ItemCount -gt 0)  
  99.     {                    
  100.         do  
  101.         {  
  102.             $smSearchMailbox.PageItemReference = $srCol[0].SearchResult.PreviewItems[$srCol[0].SearchResult.PreviewItems.Size – 1].SortValue;  
  103.             foreach ($PvItem in $srCol[0].SearchResult.PreviewItems) {  
  104.                 Write-Host ($PvItem.Topic);  
  105.             }                          
  106.             $srCol = $service.SearchMailboxes($smSearchMailbox);  
  107.             Write-Host(“Items Remaining : “ + $srCol[0].SearchResult.ItemCount);  
  108.         } whereas ($srCol[0].SearchResult.ItemCount-gt 0 );  
  109.           
  110.     }  
  111.       
  112. }  

Leave a Reply