管道从ON Powershell结果导致另一个结果



我正在尝试从另一个开发人员那里调试PowerShell脚本。这是运行PowerShell 5.1.16299.251这是给我问题的代码行(由 ->显示(:

显示:
 $CurrentProfile = $profile
$ConcourseSettings = Get-ChildItem $PSSessionRootAudatex.B2B.ConcourseUtilities.*contentscriptsConcourseSettings.ps1 -File
    if($ConcourseSettings)
    {
        $ConcourseNugetPackage = Get-Item $PSSessionRootAudatex.B2B.ConcourseUtilities.*content* 
   -->  $ConcourseScriptsPath = $ConcourseNugetPackage | Get-Item -Path scripts 
        $ConcourseProjectTemplatesDir = "$ConcourseNugetPackagedotnet" | Get-ChildItem -Filter templates 
        $GitIgnoreFile = "$ConcourseNugetPackagedotnet" | Get-ChildItem -Filter gitignore -File
        & $ConcourseSettings    
    }

如果我查看带有测试路径的$ concoursestets变量,它确实显示为真,所以我知道它正在获取该文件。这是我得到此错误的下一行:

get-item:输入对象不能绑定到命令的任何参数,因为命令不使用管道输入或输入及其属性及其属性不匹配任何接受管道输入的参数。

任何帮助都非常感谢。

您可以将可以转换为文件名字符串到 Get-Item的对象管道,也可以指定-Path参数。但是你不能同时做,这就是为什么您会遇到错误的原因。PowerShell不可能知道要使用哪种值。

我想您正在尝试将$ConcourseNugetPackage文件目录的路径分配给$ConcourseScriptsPath。这样做:

$ConcourseScriptsPath = $ConcourseNugetPackage.DirectoryName

相关内容

最新更新