title: PowerShell remote call. Access is denied
body: <p>In order to automate test releases, I need access to remote computer in other domain group.
  What I've done on remote computer:</p>
  
  <ol>
  <li>run Enable-PSRemoting</li>
  <li>set TrustedHosts "*" </li>
  <li>added https listener with self-signed certificate</li>
  <li>opened 5985 and 5986 ports</li>
  </ol>
  
  <p>So now scripts are running successfuly via PowerShell console.
  But when I'm trying to run remote script via TeamCity agent I've been receiving following error:</p>
  
  <pre><code>Connecting to remote server failed with the following error message :
  Access is denied. For more information, see the
  about_Remote_Troubleshooting Help topic.
  </code></pre>
  
  <p>TeamCity agent service is running with Local System rights.</p>
  
  <p>Session initialization</p>
  
  <pre><code>$password = ConvertTo-SecureString $appServerPwd -AsPlainText -Force 
  $appCred = New-Object System.Management.Automation.PsCredential($appServerUser,$password)
  $rs = New-PSSession -ComputerName $appServer -Credential $appCred -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) -Authentication Negotiate
  </code></pre>
  
  <p>Also when I'm trying to make remote call to domain computer via TeamCity everything works.
  Do you have any idea how to solve this issue ? </p>
  
  <p>Dima</p>