Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 421
user3772928 Avatar asked Oct 21 '25 02:10

user3772928


1 Answers

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

like image 199
Martin Avatar answered Oct 23 '25 16:10

Martin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!