【发布时间】:2020-11-27 00:31:11
【问题描述】:
我正在尝试运行 invoke-command 以在 remote computer 上启动 powershell script in a powershell file。我正在使用credentials for a user with Administrator privilege。该命令需要running powershell as an administrator执行。我尝试使用 powershell 脚本调用的应用程序存在许可问题,因此我无法将凭据更改为管理员,但需要与该特定用户本身一起运行。我曾尝试在 Invoke-Command 末尾使用 -RunAsAdministrator,但出现错误提示:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
$command = {
cd Folder
C:\Folder\build.ps1
}
Invoke-Command -ComputerName $RemoteSystemIP -ScriptBlock $command -credential $Credentials1 -ErrorAction Stop -AsJob
我正在尝试将此作为后台作业执行,这就是我添加-AsJob 参数的原因。
已经好几天了,我还没有找到解决办法。
【问题讨论】: