Gra*_*len 3 powershell powershell-4.0 type-accelerators
我无法弄清楚如何正确地转换PSSession以用作函数中的参数.
我是否需要装载组件或其他东西?我正在使用Powershell v4.
我喜欢投射我的函数参数以确保正确使用.我正在尝试的是:
function Some-Remote-Task([PSSession] $Session, [String]$Target) {
# Do stuff...
}
Run Code Online (Sandbox Code Playgroud)
但是在转换参数时出现此错误:
Unable to find type [PSSession]. Make sure that the assembly that contains this type is loaded.
Run Code Online (Sandbox Code Playgroud)
此外,$mySession.GetType()在有效会话上使用会产生以下结果:
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False PSSession System.Object
Run Code Online (Sandbox Code Playgroud)
所以看起来应该是正确的类型名称......
所有帮助表示赞赏.
Ben*_*enH 10
试试这个:
function Some-Remote-Task([System.Management.Automation.Runspaces.PSSession]$Session, [String]$Target) {
# Do stuff...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1010 次 |
| 最近记录: |