本文介绍了开始过程:访问被拒绝(即使我提供了凭据)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试执行一行代码时出现以下错误
I am getting the following error when trying to execute a line of code
Start-Process : This command cannot be executed due to the error:
Access is denied.
这是正在执行的代码
$username = "domain\username"
$passwordPlainText = "password"
$password = ConvertTo-SecureString "$passwordPlainText" -asplaintext -force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,$password
$powershellArguments = "D:\path\ps.script.ps1", "arg1", "arg2", "arg3", "arg4"
Start-Process "powershell.exe" -credential $cred -ArgumentList $powershellArguments -wait
- 此代码在本地执行时效果很好,但在通过vbs WMI调用时却无法正常运行
- 两台计算机都位于相同的域和地址范围内
- 提供的用户名和密码在两台计算机上均具有管理员权限
- 我尝试了使用
-wait
和不使用-wait
的情况,但是都没有用,并且由于用户具有特权,我希望保留它- This code works fine when executed locally, but not when called via vbs WMI
- Both computers exist in the same domain and address range
- The username and password supplied have admin privileges on both machines
- I have tried both with and without
-wait
however neither works, and due to the user being privileged, I'd prefer to keep it
推荐答案
问:您是否尝试过不使用"-wait"?
Q: Have you tried without the "-wait"?
查看此链接:
参数"-wait"禁止显示命令提示符或保留 窗口,直到该过程完成.此操作可能需要 管理员权限.
The parameter "-wait" suppresses the command prompt or retains the window until the process completes. This operation may require administrator rights.
这篇关于开始过程:访问被拒绝(即使我提供了凭据)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!