尝试执行一行代码时出现以下错误
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”吗?
看这个链接:
- http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/3983a1e4-a663-47df-86f6-874d1828ea61/
参数“-wait”抑制命令提示符或保留
窗口直到该过程完成。此操作可能需要
管理员权限。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)