Powershell 3.0中的&符号行为是否发生了变化?

时间:2011-11-13 15:39:06

标签: powershell nuget powershell-v3.0 chocolatey

windirstat上安装ilmergeChocolatey时,我遇到以下错误。我怀疑PowerShell 3.0中的&符号行为发生了变化。

Running powershell -NoProfile -ExecutionPolicy unrestricted -Command "& import-module -name  'C:\NuGet\chocolateyInstall\helpers\chocolateyInstaller.psm1'; & 'C:\NuGet\lib\ilmerge.2.10.526.4\tools\chocolateyInstall.ps1'". This may take awhile and permissions may need to be elevated, depending on the package.
ilmerge did not finish successfully. Boo to the chocolatey gods!
-----------------------
[ERROR] The expression after '&' in a pipeline element produced an invalid object. It must result in a command name, script block or Command
Info object.
-----------------------

2 个答案:

答案 0 :(得分:4)

问题不在于&符号行为我不得不用$oc = Get-Command 'Write-Host' | ?{$_.ModuleName -eq 'Microsoft.PowerShell.Utility'}替换$oc = Get-Command 'Write-Host' -Module 'Microsoft.PowerShell.Utility'以及为Write-Error包装器做类似的替换。

答案 1 :(得分:2)

如何使用-version 1.0或2.0参数启动PowerShell?然后运行上面的命令,看看是否有任何区别。

在命令行

PowerShell -version 2.0