Powershell保存功能

时间:2016-04-15 12:51:15

标签: function powershell save

我已经知道如何在powershell中创建一个函数。问题是:如何保存该功能,以便将来可以使用它?

当我在Powershell中编写myFunction {3 + 3}时,我可以在该会话中使用该函数。

Altough,如果我退出powershell并再次打开它,那个功能就消失了。我如何"保存"这个功能所以即使重新启动Powershell之后我也可以使用它?

2 个答案:

答案 0 :(得分:3)

有几种方法:

您可以将其组合成一个模块并将其与 UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarPosition: .Any, barMetrics: .Default) UINavigationBar.appearance().shadowImage = UIImage() 一起加载到脚本中或使用ps配置文件。

你也可以将任何已保存的函数点到另一个ps1(import-module functions.psm1)。

答案 1 :(得分:1)

将它放在您的Powershell个人资料中:

不要在这里解释,试试这篇文章:

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