2016-12-07 49 views
1

當我嘗試使用Invoke-Command模塊時,Powershell正在拋出錯誤。Powershell 4.0拋出錯誤爲無效命令Invoke-MsBuild

 Error: "The term 'Invoke-MsBuild' is not recognized as the name of a cmdlet,function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again." 

我還進口了使用該模塊:

Import-Module -Name <Path to the Invoke-MsBuild.psd1> 

導入它的工作原理之後,但在當前會話關閉,下一次我嘗試運行這再次顯示錯誤。模塊如何被持久化。

回答

0

從PowerShell 3.0開始,如果執行一個cmdlet,PS具有自動導入模塊的智能,這可以使用自動變量$ PSModuleAutoloadingPreference設置爲True來進行設置,但也有一些PS期望模塊的地方。我的模塊在某個自定義路徑中,你必須在每個新的會話中明確地導入。自定義模塊的最佳位置是Documents/WindowsPowerShell/Modules,如果不存在,您可以創建此文件夾結構並將模塊放置在模塊目錄下。

否則你可以在你的配置文件腳本中有這個Import-Module代碼。

更好看看這裏https://msdn.microsoft.com/powershell/reference/5.1/Microsoft.PowerShell.Core/about/about_Modules

問候,

kvprasoon

+0

你有一個正確的觀點。我的問題是通過更新PowerShell版本到5.0來解決的。 – Akki