管理Powershell模块的依赖关系

时间:2017-03-28 14:54:21

标签: powershell

我有自定义的Powershell脚本模块,我们称之为PsHandyCmdlets。在其清单中,找到以下行:RequiredModules = @('<Another module not necessarily installed yet>')

RequiredModules属性应该保证在导入当前模块之前将此处列出的任何模块导入全局范围。如果该模块不能位于机器上,则会失败。

Powershell是否提供了一种机制来确保在安装PsHandyCmdlets时安装这些模块?如果没有,是否有最佳实践来处理这种情况?

1 个答案:

答案 0 :(得分:0)

这是Rene Hernandez在他的博客上写的有关该主题的好文章,并提供了一些解决方案。他还提供了指向PowerShell模块(PSDepend)的链接,可以利用该模块来应对这一挑战。

https://bitsofknowledge.net/2018/05/17/manage-module-dependencies-in-powershell/

PSDepend模块是由RamblingCookieMonster编写的,我赞扬他们的工作具有创新性和扎实性。

https://github.com/RamblingCookieMonster/PSDepend

相关问题