2016-12-07 60 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