尝试执行一行代码时出现以下错误
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
但都没有工作,并且由于用户具有特权,我更愿意保留它