2013-07-26 79 views
2

我希望在系統啓動時導入我的自定義PowerShell模塊(.dll)。如何在系統啓動時導入PowerShell模塊?

有一種方法可以在$中寫import-module MODULE-PATH。所以無論何時我們啓動PowerShell它都會被導入。但是,如果其他某個程序使用任何命令調用powershell.exe - 從我們的自定義模塊中調用,那麼它可能不會使用配置文件。

有什麼辦法可以導入我們的自定義模塊,以便任何用戶/程序都可以使用它的命令 - 讓我們?

回答

1

也許是因爲你沒有填寫好檔案文件。已經看:

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

儘管:

$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 
+0

謝謝JP。 我看到你沒有提到存在的文件。我需要創建它們嗎? –

+0

是的,您必須以管理員身份登錄並創建您需要的人員。 – JPBlanc

2

您可以在本機配置文件,CurrentUserAllHosts比如一個導入。請參閱about_Profiles幫助主題以獲取更多信息。

+0

謝謝謝! –

相關問題