Powershell 如何从共享服务器导入splitpipeline模块?
我的脚本使用Powershell模块,带来并行进程和队列功能 脚本和模块存储在共享服务器上,如\server\c$,这样就可以从任何计算机上运行它 试图在脚本Powershell 如何从共享服务器导入splitpipeline模块?,powershell,Powershell,我的脚本使用Powershell模块,带来并行进程和队列功能 脚本和模块存储在共享服务器上,如\server\c$,这样就可以从任何计算机上运行它 试图在脚本导入模块\\server\c$\SplitPipeline的开头放置,但收到错误: import-module : Could not load file or assembly 'file://\\server\c$\SplitPipeline\SplitPipeline.dll' or one of its dependencies.
导入模块\\server\c$\SplitPipeline
的开头放置,但收到错误:
import-module : Could not load file or assembly 'file://\\server\c$\SplitPipeline\SplitPipeline.dll' or one of its dependencies.
Operation is not supported. (Exception from HRESULT: 0x80131515)
At D:\scripts\powershell\OstReport_BETA-PIPE.ps1:6 char:1
+ import-module \\server\c$\SplitPipeline
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
如果我尝试使用以下工具将其从srv复制到pc:
Copy-Item -Path \\server\c$\SplitPipeline -Destination C:\windows\system32\WindowsPowerShell\v1.0\Modules -recurse -force
我被拒绝访问
有什么想法吗
谢谢您遇到的问题是,如果没有特殊配置,无法从不受信任的UNC路径加载.NET程序集。正如您已经发现的,最简单的解决方案是首先将模块复制到本地计算机 要解决“拒绝访问”消息,请将模块复制到用户目录,而不是系统范围的目录
c:\users\<username>\Documents\WindowsPowerShell\Modules
c:\users\\Documents\WindowsPowerShell\Modules
您需要以“管理员身份”运行PowerShell,以便获得复制到系统文件夹的权限,但通常建议不要修改默认系统目录。相反,请将模块复制到您的用户文件夹中(如上所述)。谢谢,以前没有尝试过,因为如果您通过system转到env variables,则psmodulepath只会出现在system32路径中