【发布时间】:2016-09-30 17:11:55
【问题描述】:
我无法弄清楚如何正确转换 PSSession 以用作函数中的参数。
我是否必须加载程序集或其他东西?我正在使用 Powershell v4。
我喜欢转换我的函数参数以确保正确使用。我正在尝试的是:
function Some-Remote-Task([PSSession] $Session, [String]$Target) {
# Do stuff...
}
但我在转换参数时收到此错误:
Unable to find type [PSSession]. Make sure that the assembly that contains this type is loaded.
此外,在有效会话中使用 $mySession.GetType() 会产生以下结果:
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False PSSession System.Object
所以看起来这应该是正确的类型名称......
感谢所有帮助。
【问题讨论】:
标签: powershell powershell-4.0 type-accelerators