use*_*928 3 powershell function save
我已经知道如何在 powershell 中创建一个函数。问题是:如何保存该函数以便将来使用它?
当我在 Powershell 中编写 myFunction{3+3} 时,我可以在该会话中使用该函数。
但是,如果我退出 powershell 并再次打开它,该功能就消失了。如何“保存”该函数,以便在重新启动 Powershell 后也可以使用它?
有以下几种方法:
您可以将其组成一个模块并将其加载import-module functions.psm1到脚本中或通过使用 ps 配置文件。
您还可以将任何已保存的函数点源到另一个 ps1 ( . .\functions.ps1)。