我正在使用我在GitHub上找到的第三方模块,并使用以下命令导入它:
powershell Import-Module .\foo.ps1导入成功,模块运行良好。但是当我打开一个新的PowerShell终端时,它没有加载模块,我每次都必须运行Import-Module命令。可以永久加载模块吗?
我正在使用带有PowerShell v3的Windows10。
发布于 2019-01-14 07:00:05
您可以将其添加到powershell默认加载的一个配置文件中。最好的选择是
%UserProfile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 或
%UserProfile%\My Documents\WindowsPowerShell\profile.ps1
完整列表请参见https://docs.microsoft.com/en-us/previous-versions//bb613488(v=vs.85)
发布于 2019-01-14 07:11:31
因为如果您使用Install-Module将Powershell v3模块安装到正确的位置,则会自动加载它们。
以下是有关安装Powershell模块的其他信息:Installing a PowerShell Module
https://stackoverflow.com/questions/54173906
复制相似问题