[英]PowerShell remoting session variable isn't working
I am trying to run a loop using New-PSSession
and running as administrator, but I am getting an error. 我正在尝试使用
New-PSSession
并以管理员身份运行一个循环,但出现错误。
foreach ($c in $targets) {
$s = New-PSSession -ComputerName $c -Credential cred
Invoke-Command -Session $s -ScriptBlock {gci C:\temp} -RunAsAdministrator
}
I am getting the following error: 我收到以下错误:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
Invoke-Command:无法使用指定的命名参数来解析参数集。
发生错误,因为-Session
参数不能在相同的时间使用-RunAsAdministrator
参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.