Managing dependencies of Powershell modules

Question:

I have my custom Powershell script module, let’s call it PsHandyCmdlets. In its manifest the following line is found: RequiredModules = @('<Another module not necessarily installed yet>')

The RequiredModules property is supposed to guarantee that any module listed here is imported into global scope before importing the current module. This would fail if that module can’t be located on the machine.

Does Powershell provide a mechanism for ensuring that these modules are installed when PsHandyCmdlets is installed? If there isn’t, is there a best practice in place for handling this scenario?

Answer:

This is a good write up by Rene Hernandez on his blog talking about this topic and offers up some solutions. He also provides links to a PowerShell module (PSDepend) that could be leveraged to address this challenge. (link gone, but provided link to example)

https://github.com/renehernandez/powershell-dependencies-example

The module PSDepend was authored by RamblingCookieMonster which I have admired their work as being innovative and solid.

https://github.com/RamblingCookieMonster/PSDepend

Source:

Managing dependencies of Powershell modules by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply