Jenkins Job 経由で powershell を使用してコードをデプロイしたいと考えています。これは、powershell ise で正常に動作します。
$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 の唯一のコードは New-Item c:\scripts\new_file.txt です。