title: Psexec runs batch file with no errors, but has no effect
body: <p>I have a batch file that runs a powershell script_1 that invokes another powershell script_2 with elevated credentials.</p>
  
  <p>When I log into remote_server (Win Server 2012 R2, in WORKGROUP) and execute this batch script, it works perfectly.</p>
  
  <p>When I log into host_server (Win Server 2012 R2, in WORKGROUP) and execute this batch script with psexec, it returns with an error code 0, but when I test whether this works, it is as if the powershell script_1 or script_2 never executed</p>
  
  <p>On the host_server, I will run a cmd shell, Shift-right-click and select "Run as different user"</p>
  
  <p><img src="https://i.stack.imgur.com/wIGSh.png" alt="enter image description here"></p>
  
  <p>Then for username I type in "Administrator", and then the password.</p>
  
  <p>Then I execute the following</p>
  
  <pre><code>D:\pstools\psexec.exe \\IP_of_remote_server -u username -p password -accepteula C:\share\enable.bat
  </code></pre>
  
  <p>And it executes with no error, and returns code of 0</p>
  
  <p><strong>enable.bat</strong></p>
  
  <pre><code>@echo off
  powershell.exe C:\share\eLEVATE.ps1
  </code></pre>
  
  <p><strong>eLEVATE.ps1</strong></p>
  
  <pre><code>$startInfo = $NULL
  $process = $NULL
  
  
  &lt;#Previously created password file in C:\share\cred.txt, read-host -assecurestring | convertfrom-securestring | out-file C:\share\cred.txt#&gt;
  $password = get-content C:\share\cred.txt | convertto-securestring
  
  $startInfo = New-Object System.Diagnostics.ProcessStartInfo
  $startInfo.FileName = "powershell.exe"
  $startInfo.Arguments = "-noninteractive -windowstyle hidden -noprofile C:\share\remote_elevate.ps1 "
  
  $startInfo.RedirectStandardOutput = $true
  $startInfo.UseShellExecute = $false
  $startInfo.CreateNoWindow = $false
  $startInfo.Username = "Administrator"
  $startInfo.Domain = "WORKGROUP"
  $startInfo.Password = $password 
  
  $process = New-Object System.Diagnostics.Process
  $process.StartInfo = $startInfo
  $process.Start() | Out-Null
  $userId = $process.StandardOutput.ReadToEnd() 
  $process.WaitForExit()
  </code></pre>
  
  <p><strong>remote_elevate.ps1</strong></p>
  
  <pre><code>enable-psremoting -force
  </code></pre>
  
  <p>I have been trying to figure this out all morning. Thanks!</p>
  
  <p>EDIT</p>
  
  <p>I'm posting the exact screenshot of the errors I get when I enter</p>
  
  <p><code>d:\pstools\psexec.exe \\remote_IP -u Administrator -p password -accepteula cmd</code></p>
  
  <p>Then execute</p>
  
  <p><code>powershell.exe -executionpolicy bypass c:\share\eLEVATE.ps1</code></p>
  
  <p><img src="https://i.stack.imgur.com/SzDgr.png" alt="enter image description here"></p>