我想通過Jenkins Job使用PowerShell部署代碼。這在powershell ise中工作正常。通過本地系統帳戶通過PowerShell提升信用度
$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
但是當我從使用本地系統的Jenkins運行它時,出現以下錯誤消息。
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 $
如果更改我將Jenkins服務更改爲另一個帳戶它的工作。爲什麼不能在本地系統帳戶下提升權限?
注:在test.ps1唯一的代碼是新建項目C:\腳本\ new_file.txt
要保存憑據我打開命令提示符作爲本地系統這樣 'PSEXEC -i -s cmd.exe' 你需要右鍵點擊PSEXEC並勾選以管理員身份運行這個工作。 然後我第一次運行我的powershell腳本。 我被提示輸入密碼,然後我得到了Acces Denied! 最後我改變了詹金斯帳戶使用別的東西。然而,這裏有一個解決方案,我沒有嘗試 [鏈接](http://www.brandonmartinez.com/2013/04/24/resolve-access-is-denied-using-psexec-with-a-local-管理員帳戶) –