mho*_*321 8 permissions powershell
尝试执行一行代码时出现以下错误
Start-Process : This command cannot be executed due to the error:
Access is denied.
Run Code Online (Sandbox Code Playgroud)
这是正在执行的代码
$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
Run Code Online (Sandbox Code Playgroud)
-wait但由于用户享有特权,我宁愿保留它问:你尝试过不加“-wait”吗?
看这个链接:
参数“-wait”会抑制命令提示符或保留窗口,直到进程完成。此操作可能需要管理员权限。
| 归档时间: |
|
| 查看次数: |
10280 次 |
| 最近记录: |