title: Alternative to AddPsSnapin to load Cmdlet in runspace
body: <p>I'm attempting to test a C# Cmdlet's interaction with PowerShell's pipelie.</p>
  
  <p>When I attempt to register the Cmdlet's snap-in, I get an error (<code>No snap-ins have been registered for Windows PowerShell version 4.</code>).  I suspect that this is because my Windows account doesn't have the rights to register snap-ins.</p>
  
  <p>Code:</p>
  
  <pre><code>using (Runspace runspace = RunspaceFactory.CreateRunspace(config))
  {
      PSSnapInException warning;
  
      // error generated on this line
      config.AddPSSnapIn("PsEnterprise.PsEnterpriseSnapIn", out warning);
  
      runspace.Open();
  
      using (Pipeline pipeline = runspace.CreatePipeline())
      {
  
          // arrange
          Command command = new Command("New-PsDrive");
          command.Parameters.Add("Name", "DEV");
          command.Parameters.Add("PsProvider", "MyProvider");
          command.Parameters.Add("Root", "DEV:\\");
  
          pipeline.Commands.Add(command);
  
          // act
          Collection&lt;PSObject&gt; actual = pipeline.Invoke();
  
          // assert
          Assert.AreEqual&lt;int&gt;(1, actual.Count);
          Assert.IsNotNull(actual[0]);
          Assert.IsInstanceOfType(actual, typeof(MyDriveInfo));
  
      } // Pipeline
  } // Runspace
  </code></pre>
  
  <p>Is there another way to reference the Cmdlet such that it can be tested in this manner?</p>