How to get the modules root directory?

Hi guys,

I’m currently working on several module functions.
Now I need to get the modules root directory. Do I need to work with `$PSScriptRoot`, `$PSCmdlet` or `$MyInvocation`? - I thought there is an automatic variable ?

Hi OCram85,

$MyInvocation.MyCommand.Module.ModuleBase should work.

Ahh nice… That`s what I was searching for :slight_smile:

Try this:

$ENV:PSModulePath -split ‘;’

Well, this would return a list of all available module paths. But I really need the current root directory of the module I’m currently in. So @daniel-krebs idea seems to be the easiest way. (At least for me ^^).

But thanks anyway!