在执行某行代码时,我遇到了以下错误:
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
,但都不起作用,由于用户拥有特权,我更愿意将其保留。