2010-12-22 31 views
1

我有一個模塊位於網絡共享上,我希望在遠程會話期間加載到網絡上的其他服務器。位於網絡共享上的導入模塊

這裏我的命令:

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 

都是模塊無法從網絡共享或加載什麼我做錯了?

感謝

回答

0

默認情況下,它通過在PSModulePath環境變量中列出的任何路徑(S)名稱查找模塊。我知道你也可以提供絕對路徑,但我從來沒有嘗試過UNC。

也就是說,模塊文件名以.psm1,.psd1或.dll結尾 - 「.misc」不是有效的模塊文件名。從幫助:

Specifies the names of the modules to import. Enter the name of the module or the name of a file in the module, such as a .psd1, .psm1, .dll, or ps1 file. File paths are optional. Wildcards are not permitted. You can also pipe module names and file names to Import-Module. 

If you omit a path, Import-Module looks for the module in the paths saved in the PSModulePath environment variable ($env:PSModulePath). 

嘗試將您的模塊重命名爲.psm1(如果它實際上是一個腳本模塊)。

+1

感謝,但這不是它。當我不遠程訪問另一臺機器時,此導入模塊語句正常工作。我接近本網站上的信息:http://www.ravichaganti.com/blog/?p=1230 – ChiliYago 2010-12-22 19:44:04