我创建了以下代码&由于执行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
答案 0 :(得分:0)
Start-Process:由于错误,无法执行此命令: 访问被拒绝。在 C:\ WINDOWS \ system32 \设置\ systemprofile \应用程序数据\本地的\ Temp \ PRISMA-AMR-JOB1-87-ScriptBuildTask-8569094554411403512.ps1:38 炭:18
根据此错误代码,您似乎还没有添加您的用户&#34;域\用户名&#34;到本地计算机政策 - &gt;用户权利分配。
有关用户权利分配的详情,请参阅此link。
此外,在类似的情况下,请参阅it。
注意强>:
要在命令提示符或搜索中打开本地组策略,请键入gpedit.msc
,然后单击“确定”或按ENTER
。