Import-Module requires -Force when using in TaskScheduler?

I’ve weird situation. I’ve couple of PowerShell Modules. I added script to Task Scheduler (based on Events) and it works for most part… except that if I want to call command from another module I have to this within that module and not on beginning.

For example:

Import-Module <1> -Force

Import-Module <2> -Force

Call-Function X from Module <1>

In Call-Function I call function from module <2> it doesn’t work

I add Import-Module <2> in Call-Function it doesn’t work… I add Import-Module <2> -Force it works.

Now I’ve wasted lots of hours on figuring this out and I can’t think of any sane explanation. Anyone knows?

submitted by /u/MadBoyEvo
[link] [comments]

Leave a Reply