by

Turning off the Studying / Preview Pane on all folders in OWA in Alternate 2013 and Alternate On-line in EWS with Powershell

Turning off the Studying / Preview Pane on all folders in OWA in Alternate 2013 and Alternate On-line in EWS with Powershell Alternate 2013 and Alternate On-line has a cool new characteristic in OWA to allow you to management the Studying pane setting on all folders in your Mailbox in OWA eg. (in earlier variations you needed to handle it your self per folder).

While you set this setting in OWA and examine the “Apply to all folders” field, in your mailbox it units a configuration setting referred to as GlobalReadingPanePosition within the OWA.UserOptions FAI (Folder Related Merchandise) within the Non_IPM Root of your Mailbox. The next values management the place of the Studying Pane on all folders

0 – Hides the Studying Pane
1 – Exhibits the Studying Pane on the Rights (that is the default)
2 – Exhibits the Studying Pane on the backside

To Entry this FAI Merchandise in EWS you utilize the UserConfiguration class which makes accessing the Roaming Dictionary construction the place this specific worth is held very easy. Eg the next script will flip the Studying pane off on all Folders within the mailbox its ran in opposition to. I’ve put a download of this script right here the code itself seems like

  1. ## Get the Mailbox to Entry from the 1st commandline argument  
  2.   
  3. $MailboxName = $args[0]  
  4.   
  5. ## Load Managed API dll    
  6. Add-Kind -Path “C:Program FilesMicrosoftExchangeWeb Services2.0Microsoft.Exchange.WebServices.dll”    
  7.     
  8. ## Set Alternate Model    
  9. $ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Alternate2010_SP2    
  10.     
  11. ## Create Alternate Service Object    
  12. $service = New-Object Microsoft.Alternate.WebServices.Information.ExchangeService($ExchangeVersion)    
  13.     
  14. ## Set Credentials to use two choices are availible Option1 to use explict credentials or Choice 2 use the Default (logged On) credentials    
  15.     
  16. #Credentials Choice 1 utilizing UPN for the home windows Account    
  17. $psCred = Get-Credential    
  18. $creds = New-Object System.Web.NetworkCredential($psCred.UserName.ToString(),$psCred.GetNetworkCredential().password.ToString())    
  19. $service.Credentials = $creds        
  20.     
  21. #Credentials Choice 2    
  22. #service.UseDefaultCredentials = $true    
  23.     
  24. ## Select to ignore any SSL Warning points precipitated by Self Signed Certificates    
  25.     
  26. ## Code From http://poshcode.org/624  
  27. ## Create a compilation atmosphere  
  28. $Supplier=New-Object Microsoft.CSharp.CSharpCodeProvider  
  29. $Compiler=$Supplier.CreateCompiler()  
  30. $Params=New-Object System.CodeDom.Compiler.CompilerParameters  
  31. $Params.GenerateExecutable=$False  
  32. $Params.GenerateInMemory=$True  
  33. $Params.IncludeDebugInformation=$False  
  34. $Params.ReferencedAssemblies.Add(“System.DLL”) | Out-Null  
  35.   
  36. $TASource=@ 
  37.   namespace Native.ToolkitExtensions.Web.CertificatePolicy{ 
  38.     public class TrustAll : System.Web.ICertificatePolicy { 
  39.       public TrustAll() {  
  40.       } 
  41.       public bool CheckValidationResult(System.Web.ServicePoint sp, 
  42.         System.Safety.Cryptography.X509Certificates.X509Certificates cert,  
  43.         System.Web.WebRequest req, int drawback) { 
  44.         return true; 
  45.       } 
  46.     } 
  47.   } 
  48. @   
  49. $TAResults=$Supplier.CompileAssemblyFromSource($Params,$TASource)  
  50. $TAAssembly=$TAResults.CompiledAssembly  
  51.   
  52. ## We now create an occasion of the TrustAll and connect it to the ServicePointManager  
  53. $TrustAll=$TAAssembly.CreateInstance(“Local.ToolkitExtensions.Net.CertificatePolicy.TrustAll”)  
  54. [System.Net.ServicePointManager]::CertificatePolicy=$TrustAll  
  55.   
  56. ## finish code from http://poshcode.org/624  
  57.     
  58. ## Set the URL of the CAS (Shopper Entry Server) to use two choices are availbe to use Autodiscover to discover the CAS URL or Hardcode the CAS to use    
  59.     
  60. #CAS URL Choice 1 Autodiscover    
  61. $service.AutodiscoverUrl($MailboxName,{$true})    
  62. “Using CAS Server : “ + $Service.url     
  63.      
  64. #CAS URL Choice 2 Hardcoded    
  65.     
  66. #$uri=[system.URI] “https://casservername/ews/exchange.asmx”    
  67. #$service.Url = $uri      
  68.     
  69. ## Elective part for Alternate Impersonation    
  70.     
  71. #$service.ImpersonatedUserId = new-object Microsoft.Alternate.WebServices.Information.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $MailboxName)   
  72.   
  73. $folderid= new-object Microsoft.Alternate.WebServices.Information.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Root,$MailboxName)       
  74. #Specify the Root folder the place the FAI Merchandise is    
  75. $UsrConfig = [Microsoft.Exchange.WebServices.Data.UserConfiguration]::Bind($service“OWA.UserOptions”$folderid, [Microsoft.Exchange.WebServices.Data.UserConfigurationProperties]::All)    
  76. if($UsrConfig.Dictionary.ContainsKey(“GlobalReadingPanePosition”)){    
  77.     $UsrConfig.Dictionary[“GlobalReadingPanePosition”] = 0    
  78. }    
  79. else{    
  80.     $UsrConfig.Dictionary.Add(“GlobalReadingPanePosition”,0)    
  81. }  
  82. $UsrConfig.Replace()    
  83. “Item updated”