user3772928
user3772928

Reputation: 33

Powershell save functions

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?

Upvotes: 3

Views: 8683

Answers (2)

Martin
Martin

Reputation: 1963

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).

Upvotes: 5

Scepticalist
Scepticalist

Reputation: 3923

Put it in your Powershell profile:

Rather than explain it here, try this article:

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

Upvotes: 3

Related Questions