2

I have a powershell module file C:\Program Files\WindowsPowerShell\Modules\MathModule\MathModule.psm1

I have added this so that I can access the functions in the module easily from anywhere. Lets say this contains a function called Add-Numbers.

I have another project where I have MathModule.psm1 with another implementation of Add-Numbers function. From test.ps1 in the same directory I write

Import-Module ".\MathModule.psm1"
Add-Numbers 1 2 3

I was expecting this to use the Add-Numbers definition from the locally imported MathModule.psm1. However, it continues to use the definition from C:\Program Files\WindowsPowerShell\Modules\MathModule\MathModule.psm1

How can I override Add-Numbers from local MathModule.psm1 in test.ps1 instead of the one in Program Files?

1
  • 1
    Try this: Import-Module ".\MathModule.psm1" -Force Commented Jun 28, 2017 at 4:49

1 Answer 1

2

If the MathModule module was previously loaded you'll need to add -Force to truly reload it (even from a different psm1 file).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.