导入模块位于网络共享上
我有一个位于网络共享上的模块,我希望在远程会话期间加载到网络上的其他服务器。
这是我的命令:
enter-pssession remoteserver
import-module \\shareserver\sharefolder\SPModule.misc
这是错误:
Import-Module : The specified module 'SPModule.misc' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (SPModule.misc:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
模块无法从网络共享加载还是我做错了什么?
谢谢
I have a module located on a network share the I wish to load during remote session to other servers on my network.
Here my commands:
enter-pssession remoteserver
import-module \\shareserver\sharefolder\SPModule.misc
Here is the error:
Import-Module : The specified module 'SPModule.misc' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (SPModule.misc:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Are modules not able to load from network shares or what am I doing wrong?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
(将此添加为答案以便更容易查找。)
您需要使用 CredSSP 启用第二跳远程处理。
PowerShell 2.0 远程处理指南:第 12 部分 – 使用 CredSSP 进行多跳身份验证
用于第二跳远程处理的 CredSSP
PowerShell 远程处理和“双跳”问题
(Adding this as an answer to make it easier to find.)
You need to enable second-hop remoting with CredSSP.
PowerShell 2.0 remoting guide: Part 12 – Using CredSSP for multi-hop authentication
CredSSP for second-hop remoting
PowerShell Remoting and the “Double-Hop” Problem
默认情况下,它会在 PSModulePath 环境变量中列出的任何路径中按名称查找模块。我知道你也可以提供绝对路径,但我从未尝试过 UNC。
也就是说,模块文件名以 .psm1、.psd1 或 .dll 结尾 - “.misc”不是有效的模块文件名。从帮助中:
尝试将模块重命名为 .psm1 (如果它实际上是脚本模块)。
By default, it looks for modules by name in whatever path(s) are listed in the PSModulePath environment variable. I know you can also provide an absolute path, but I've never tried a UNC.
That said, module filenames end in either .psm1, .psd1, or .dll - ".misc" isn't a valid module filename. From the help:
Try renaming your module to .psm1 (if it is in fact a Script Module).
当创建 PS 会话并通过 Kerberos 进行身份验证时,该会话不支持双跳。因此,PS会话无法利用网络资源进行认证。
解决:
在作为 Enter-PSSession 命令的目标的计算机上,运行以下命令:
在运行 Enter-PSSession 命令的计算机上,运行以下命令:
参考:https://support.microsoft.com/af-za/help/4076842
When a PS session is created and authenticates through Kerberos, the session doesn't support double hop. Therefore, the PS session can't authenticate by using network resources.
Resolution:
On the computer that is the target of the Enter-PSSession command, run this command:
On the computer on which you run the Enter-PSSession command, run this command:
Reference: https://support.microsoft.com/af-za/help/4076842