Author Posts

March 21, 2017 at 3:22 pm

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 ?

March 21, 2017 at 3:38 pm

Hi OCram85,

$MyInvocation.MyCommand.Module.ModuleBase should work.

March 21, 2017 at 3:49 pm

Ahh nice... That`s what I was searching for 🙂

March 21, 2017 at 4:22 pm

Try this:

$ENV:PSModulePath -split ';'

March 23, 2017 at 7:49 am

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!