[英]Unable to import installed PowerShell module
I've created an Azure Artifacts feed to host my PowerShell modules and I'm able to install them locally to a directory listed in the PSModulePath list.我创建了一个 Azure Artifacts 源来托管我的 PowerShell 模块,并且我能够将它们本地安装到 PSModulePath 列表中列出的目录中。
My issue is that when I come to use the module it is not available in active memory and I get an error when trying to import the module by name:我的问题是,当我开始使用该模块时,它在活动内存中不可用,并且在尝试按名称导入模块时出现错误:
Import-Module : The specified module 'module-name' was not loaded because no valid module file was found in any module directory.
If I use Get-Module, the module is not listed.如果我使用 Get-Module,则不会列出该模块。
If I use Get-InstalledModule, it appears in the list.如果我使用 Get-InstalledModule,它会出现在列表中。
If I import the module using the full path then I am able to use the module, but I don't want to specify the full path as I will eventually be using the module in a DevOps release pipeline.如果我使用完整路径导入模块,那么我可以使用该模块,但我不想指定完整路径,因为我最终将在 DevOps 发布管道中使用该模块。
In this scenario, how can I import the module into my script?在这种情况下,如何将模块导入我的脚本?
Using Test-ModuleManifest identified that the ModuleVersion didn't match the version number in the module file path.使用 Test-ModuleManifest 确定 ModuleVersion 与模块文件路径中的版本号不匹配。 Updating the ModuleVersion resolved the issue.
更新 ModuleVersion 解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.