Permanently add PowerShell module? (Import-Module)

梦想与她 提交于 2019-12-12 17:25:22

问题


I'm using a third-party module I found on GitHub and importing it with:

powershell Import-Module .\foo.ps1

This imports successfully and the module works great. But when I open a new PowerShell terminal, it doesn't load the module, I have to run the Import-Module command everytime. Is it possible to have modules load permanently?

I'm using Windows 10 with PowerShell v3.


回答1:


You can add it to one of your profiles that powershell loads by default. Best bet is

%UserProfile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 

or

%UserProfile%\My Documents\WindowsPowerShell\profile.ps1

see https://docs.microsoft.com/en-us/previous-versions//bb613488(v=vs.85) for the full list




回答2:


Since Powershell v3 Modules will be loaded automatically if you install them to the right place with Install-Module.

Here are additional information about installing Powershell modules: Installing a PowerShell Module



来源:https://stackoverflow.com/questions/54173906/permanently-add-powershell-module-import-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!