質問

I want my custom PowerShell module (.dll) to be imported at the time of system start-up.

There is a way to write import-module MODULE-PATH in $profile file. so that whenever we launch PowerShell it gets imported. But if some other program is calling powershell.exe with any command-let from our custom module then it may not use profile.

Is there any way by which we can import our custom module so that any user/program can use the command-lets from it?

役に立ちましたか?

解決

Perhaps because you didn't fill the correct profile file. Look at :

$profile.AllUsersAllHosts
C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

instead of :

$profile.AllUsersCurrentHost
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1

$profile.CurrentUserAllHosts
C:\Users\JPB\Documents\WindowsPowerShell\profile.ps1

$profile.CurrentUserCurrentHost
C:\Users\JPB\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

他のヒント

You can import it in one of the machine profiles, CurrentUserAllHosts for instance. See the about_Profiles help topic for more information.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top