4

I already know how to make a function in powershell. The problem is: How do I save that function so I can use it in the future?

When I write myFunction{3+3} in Powershell I can use that function in that session.

Altough, if I quit powershell and open it again, that function is gone. How do I "save" the function so I can use it even after I restart Powershell?

2 Answers 2

6

There are several ways:

You can compose it to a module and load it with import-module functions.psm1 into a script or via use the ps profile.

You can also dot sourc any saved functions into another ps1 ( . .\functions.ps1).

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

Comments

4

Put it in your Powershell profile:

Rather than explain it here, try this article:

http://www.howtogeek.com/50236/customizing-your-powershell-profile/

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.