title: Elevate creditals with powershell via Local System Account
body: <p>I want to deploy code using powershell via Jenkins Job. This works fine in the powershell ise.</p>
  
  <pre><code>$username = "mydomain\builder"
  $password = "notmypassword"
  $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
  $Arguments = "-ExecutionPolicy Bypass -File C:\Test.ps1 -NoNewWindow -WorkingDirectory C:\Windows\System32\WindowsPowerShell\v1.0 -NoLogo -NonInteractive"
  
  Start-Process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Credential $credentials -ArgumentList $Arguments
  </code></pre>
  
  <p>But when I run it from Jenkins which use the local system I get the following error message.</p>
  
  <pre><code>Start-Process : This command cannot be run due to the error: Access is denied.
  At C:\WINDOWS\TEMP\hudson5557889306949142167.ps1:7 char:1
  + Start-Process powershell.exe -Credential $credentials -ArgumentList $
  </code></pre>
  
  <p>If change I change the Jenkins service to another account it works. Why won't elevated permission work under the local system account?</p>
  
  <p>note: the only code in test.ps1 is New-Item c:\scripts\new_file.txt</p>