0

I am trying to call a function in a PowerShell script in the same directory. However, when I call it, I get this error:

The term 'functionName' is not recognized as the name of a cmdlet, function, script...

Any idea why this occurs? I also tried dot loading the script first like this before calling the function:

.\Script.psm1
2
  • 2
    PSM1? Is your function in a module? Do you need to run Import-Module first? Commented Jan 4, 2016 at 22:51
  • Thanks, importing the module worked. Commented Jan 4, 2016 at 22:56

1 Answer 1

2

.\Script.psm1 would run the script (script module, actually) in a child context. To be able to use functions from it in the current context you need to run/load it in the current context. That can be done via dot-sourcing for regular scripts, or via Import-Module (for modules).

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.