Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The actual code adapted from from MSDN <a href="http://msdn.microsoft.com/en-us/library/exchange/bb332449(v=exchg.80).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/exchange/bb332449(v=exchg.80).aspx</a> can be tricky because you have to get the permissions right and run it on a macine with all of the Exchange plug-ins:</p> <pre><code>using Microsoft.Win32; using System.Collections.ObjectModel; using System.IO; using System.Management.Automation.Runspaces; using System.Reflection; public static Runspace GetExchangeRunspace() { return GetExchangeRunspace(""); } public static Runspace GetExchangeRunspace(string snapIn) { string consoleFilePath = (ScriptEngine.GetExchangeAssemblyPath() + "bin\\exshell.psc1").Replace("Exchange Server", "EXCHAN~1"); Response.Write("&lt;br/&gt;" + consoleFilePath); PSConsoleLoadException warnings = null; RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(consoleFilePath, out warnings); if ((snapIn + "").Trim().Length &gt; 0) { PSSnapInException warning = null; Response.Write("&lt;br/&gt;Start AddPSSnapIn..." + snapIn); Response.Write("&lt;br/&gt;" + runspaceConfiguration.AddPSSnapIn(snapIn, out warning)); Response.Write("&lt;br/&gt;" + warning); } return RunspaceFactory.CreateRunspace(runspaceConfiguration); } private static string GetExchangeAssemblyPath() { string path = ""; try { RegistryKey key = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\Microsoft\\ExchangeServer\\v14\\Setup"); // or your version if (key != null) { path = Path.GetFullPath(string.Concat(key.GetValue("MsiInstallPath"))); Response.Write(path); } } catch (Exception ex) { } return path; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload