title: Lync PowerShell: Enable a User for Enterprise Voice
body: <p>I have the below code used for enabling a user for Lync using Power Shell commands. The code has two steps, the first one is to enable the user, the second one is to enable Enterprise Voice.</p>
  
  <pre><code> using (Pipeline pipe = runspace.CreatePipeline())
   {
       var enableCsUser = new Command("Enable-CsUser");
       enableCsUser.Parameters.Add("Identity", upn);
       enableCsUser.Parameters.Add("SipAddress", "sip:" + sipAddress);
       enableCsUser.Parameters.Add("RegistrarPool", LyncPool);
       pipe.Commands.Add(enableCsUser);
       InvokePipeline(pipe);
   }
   using (Pipeline pipe = runspace.CreatePipeline())
   {
       var setCsUser = new Command("Set-CsUser");
       setCsUser.Parameters.Add("Identity", upn);
       setCsUser.Parameters.Add("EnterpriseVoiceEnabled", true);
       pipe.Commands.Add(setCsUser);
       InvokePipeline(pipe);
   }
  </code></pre>
  
  <p>The first part works fine and the user is enabled. the second part throws an exception at <code>InvokePipeline(pipe);</code> with no clear reason for me. I've followed the following articles <a href="http://technet.microsoft.com/en-us/library/gg398510.aspx" rel="nofollow">here</a>, <a href="http://allunifiedcom.wordpress.com/2011/07/14/usingpowershell-to-enable-users-for-lync-and-exchange-unified-messaging/" rel="nofollow">here</a> and <a href="http://gotspeechguy.com/2011/09/07/lync-powershell-enable-a-user-for-enterprise-voice/" rel="nofollow">here</a>.</p>
  
  <p>The exception details are below.</p>
  
  <pre><code>System.Management.Automation.RemoteException: Management object not found for identity "lfigo@fabrekam.cloudyCloud.com".
  at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings)
  at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
  at System.Management.Automation.PowerShell.Invoke(IEnumerable input)
  at System.Management.Automation.RemotePipeline.Invoke(IEnumerable input)
  at System.Management.Automation.Runspaces.Pipeline.Invoke()
  </code></pre>
  
  <p>Do I miss something?</p>