【发布时间】:2017-10-06 21:14:00
【问题描述】:
我创建了以下代码,但由于执行 powershell.exe 时启动进程的访问被拒绝错误而失败。
$username = "domain\username"
$password = "Welcome1234$"
$PSArgs = "D:\test.ps1"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $username,
$securePassword
Start-Process Powershell.exe -Credential $credential $PSArgs
错误:
Start-Process : This command cannot be executed due to the error: Access is denied
Start-Process : This command cannot be executed due to the error: Access is denied.
At C:\Windows\system32\config\systemprofile\AppData\Local\Temp\PRISMA-AMR-JOB1-87-ScriptBuildTask-8569094554411403512.ps1:38 char:18
+ Start-Process <<<< C:\Windows\System32\cmd.exe -arg "/C" -Credential $credential + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
【问题讨论】:
标签: powershell azure