我有" ModuleA"从模块中导入函数" ADAutoDeployUtilities"和#34; Common_LoggingNotifications"使用下面的代码。但是,当我尝试使用-force导入Common_LoggingNotifications时,我一直收到异常(如下所列)。如果我不加载Common_LoggingNotifications,则只导入ADAutoDeployUtilities函数(它不包含writeJobLog)并且一切运行正常,但在服务器上运行时我得到指示的异常。我还使用-verbose提供了输出的屏幕截图。我从屏幕截图中无法理解的两件事情;有什么想法吗?
在" ModuleA" ...
# Load Module Dependencies
$ModulesPath = $PreCompareInfoObject.ModulesPath # "c:\modules" for example
$ModulesList = "ADAutoDeployUtilities,Common_LoggingNotifications"
$ModulesList.Split(",") | foreach {
if (-not (get-module $ModulesPath$_)) {
#import-module $ModulesPath$_ -ErrorAction SilentlyContinue
import-module $ModulesPath$_ -force -verbose
}
}
# writeJobLog below throws error: The term 'writeJobLog' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again
writeJobLog "xxxxx"
运行" ModuleA" ...
后的屏幕截图