title: C# Powershell Interop
body: <p>The Sys Admin guy is writing some common housekeeping Power Shell scripts. Predominantly for AD management (updating exchange details, moving people around security groups etc.)</p>
  
  <p>I'd like to use these scripts from C# (I intend to write it as a library, consumed by a web site).</p>
  
  <p>I've seen this <a href="http://www.codeproject.com/KB/cs/HowToRunPowerShell.aspx" rel="nofollow noreferrer">code project article</a> which looks interesting and a good place to start.</p>
  
  <p>Does anyone have any experience of Power Shell interop? Can anyone think of any major gotchas before I jump head first into a spike?</p>
  
  <p><strong>Extra Information:</strong></p>
  
  <p>I appreciate there are logistical challenges particularly with CI and versioning. </p>
  
  <p>The plan was initially to use Directory Services, exposing services through a web API and CmdLets. Unfortunately we’re having difficulties with Directory Services (e.g. truncated results for large sets). </p>
  
  <p>In the meanwhile, rather than use an inconsistent mix, I figured I should investigate using the Sys Admins’ scripts. Why re-invent the wheel?</p>
  
  <p>I’ve already written my domain model. I intend to implement the repository pattern so I can abstract out AD / Exchange integration allowing different implementations in the future.</p>