title: Powershell remoting - cannot execute an exe as another user
body: <p>I've a commandline program (c#) that encrypts config files based on machine key.
  A powershell script copies the build to a Target Server, modifies configs accordingly and installs windows services. 
  All the windows services run as local system account (standard user, non-admin) - let's call this account "locuser". </p>
  
  <p>The Target Server is a Win 2012 R2 Server. All of the above is achieved by PS remoting from the Build Server to this Target server.</p>
  
  <p>Now, I need to run the encrypt commandline program as "locuser", so that the program can use the account specific key to do the encryption.
  I know that this can be easily achieved by calling <code>Start-Process</code> cmdlet with <code>-Credentials</code> parameter. Well, here's the catch, the above works fine, if I remote in (RDP) to the Target Server and then run the <code>Start-Process .... -Credential $cred</code> from a Powershell Console.</p>
  
  <p>However, I need this to be working while I remote-in (using my scripts) to the TargetServer whilst deploying. When I remote-in to the TargetServer I use credentials that has Admin privileges.</p>
  
  <p>I've tried the following</p>
  
  <ol>
  <li>I've granted "locuser" both "Full Control" and "Invoke (Execute)" permissions by using the <code>Set-PSSessionConfiguration -Name Microsoft.PowerShell -ShowSecurityDescriptorUI</code> command. I've run this command for both <code>Microsoft.Powershell</code> and <code>Microsoft.Powershell32</code> - Still get Access Denied</li>
  <li>I've edited the "Local Security Policy"->"Local Policies"->"User Rights Assignment"->Impersonate a client after authentication - and added both the Admin account (that I login with) and the "locuser" account - Still get Access Denied</li>
  <li>I've also granted locuser admin rights - Still get Access Denied</li>
  </ol>
  
  <p>I'm pretty sure, there is some configuration on the PS Remoting Side of things that I'm missing out but can't figure out what - because all Powershell throws me is a <code>Access Denied</code> error (see screenshot) with little to no useful information to troubleshoot further.</p>
  
  <p>Also, checked Event logs for any traces but to no avail.</p>
  
  <p><a href="https://i.stack.imgur.com/EMYDY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EMYDY.png" alt="PS Remoting Error"></a></p>