2014-07-03 55 views
1

我的脚本使用Powershell splitpipeline模块来实现并行进程和队列功能。如何从共享服务器导入splitpipeline模块?

脚本和模块存储在共享服务器上,如\ server \ c $,这个想法可以从任何计算机上运行它。

试图把在脚本import-module \\server\c$\SplitPipeline的begining,但我收到的错误:

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 

我得到一个访问被拒绝

任何想法?

感谢

回答

3

您遇到的问题是,.NET程序集不能从不受信任的UNC路径来加载,无需特殊的配置。正如您已经发现的,最简单的解决方案是先将模块复制到本地计算机。

要解决“拒绝访问”消息,请将模块复制到您的用户目录,而不是系统范围的目录。

c:\users\<username>\Documents\WindowsPowerShell\Modules 

您需要以有权复制到系统文件夹中运行PowerShell的“以管理员身份”,但通常建议不要修改默认的系统目录下。相反,将模块复制到您的用户文件夹(如上所述)。

+0

感谢,没有尝试过,因为如果你去env变量低谷系统,为psmodulepath只是出现system32路径 – pedaleo