简体   繁体   English

PowerShell 和 TFS | 术语“tfpt”未被识别为 cmdlet 的名称

[英]PowerShell and TFS | The term 'tfpt' is not recognized as the name of a cmdlet

Running locally on my client (not TFS server) Windows 10 pro workstation and getting the error.在我的客户端(不是 TFS 服务器)Windows 10 专业版工作站上本地运行并出现错误。 What am I missing?我错过了什么?

> tfpt : The term 'tfpt' 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. At C:\DeploymentManagement\Tests\GetBranchInfo.ps1:18
> char:21
> + $WorkItemResults =  tfpt query /format:tsv /collection:$TfsServer /wi ...
> +                     ~~~~
>     + CategoryInfo          : ObjectNotFound: (tfpt:String) [], CommandNotFoundException
>     + FullyQualifiedErrorId : CommandNotFoundException   The variable '$WorkItemResults' cannot be retrieved because it has not been set. At
> C:\DeploymentManagement\Tests\GetBranchInfo.ps1:19 char:20
> + $WorkItemResults = $WorkItemResults -replace  "(.*)Query results:.*", ...
> +                    ~~~~~~~~~~~~~~~~
>     + CategoryInfo          : InvalidOperation: (WorkItemResults:String) [], RuntimeException
>     + FullyQualifiedErrorId : VariableIsUndefined   The variable '$WorkItemResults' cannot be retrieved because it has not been set. At
> C:\DeploymentManagement\Tests\GetBranchInfo.ps1:21 char:20
> + $WorkItemResults = $WorkItemResults.Split("`t")
> +                    ~~~~~~~~~~~~~~~~
>     + CategoryInfo          : InvalidOperation: (WorkItemResults:String) [], RuntimeException
>     + FullyQualifiedErrorId : VariableIsUndefined   The variable '$WorkItemResults' cannot be retrieved because it has not been set. At
> C:\DeploymentManagement\Tests\GetBranchInfo.ps1:24 char:17
> + foreach($row in $WorkItemResults)
> +                 ~~~~~~~~~~~~~~~~
>     + CategoryInfo          : InvalidOperation: (WorkItemResults:String) [], RuntimeException
>     + FullyQualifiedErrorId : VariableIsUndefined

Code sample below下面的代码示例

# Enforce coding rules
Set-StrictMode -version 2.0

# Loads Windows PowerShell snap-in if not already loaded
 if ( (Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null )
 {
    Add-PSSnapin Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue
 }

$PbiParm = 89306  

# Get Iteration Path and PBI Title
$query = "SELECT [System.IterationPath], [System.Title] " + 
            "FROM WorkItems WHERE [System.Id] = " + $PbiParm

$TfsServer = "http://***tfs01:8080/tfs/Project"

$WorkItemResults =  tfpt query /format:tsv /collection:$TfsServer /wiql:$query
$WorkItemResults = $WorkItemResults -replace  "(.*)Query results:.*", ""

$WorkItemResults = $WorkItemResults.Split("`t")

$Index = 0
foreach($row in $WorkItemResults)
{
    $Index++

    Write-Host $Index

    if ($Index -eq 1 -or $Index -eq 2)
    {
        continue
    }

    if ($Index -eq 3)
    {
        $SprintName = $row
    }

    if ($Index -eq 4)
    {
        $PbiTitle = $row
    }

    if ($Index -eq 5)
    {
        break
    }
}

Tools: PowerShell ISE, TFS Server 2012, Windows PowerShell 2.0 Engine, and also installed: C:\\Program Files (x86)\\Microsoft Team Foundation Server 2012 Power Tools C:\\Program Files (x86)\\Microsoft Team Foundation Server 2013 Power Tools C:\\Program Files (x86)\\Microsoft Team Foundation Server 2015 Power Tools工具:PowerShell ISE、TFS Server 2012、Windows PowerShell 2.0 Engine,并且还安装了:C:\\Program Files (x86)\\Microsoft Team Foundation Server 2012 Power Tools C:\\Program Files (x86)\\Microsoft Team Foundation Server 2013 Power Tools C:\\Program Files (x86)\\Microsoft Team Foundation Server 2015 Power Tools

> Get-Host | Select-Object Version >>  Version       
> -------       
> 5.1.17763.1007

Tried to run the command :尝试运行命令:

powershell -Command get-pssnapin -Registered

RESULT:结果:

Name : SqlServerCmdletSnapin100 PSVersion : 2.0 Description : This is a PowerShell snap-in that includes various SQL Server cmdlets.名称:SqlServerCmdletSnapin100 PSVersion:2.0 描述:这是一个包含各种 SQL Server cmdlet 的 PowerShell 管理单元。

Name : SqlServerProviderSnapin100 PSVersion : 2.0 Description : SQL Server Provider名称:SqlServerProviderSnapin100 PSVersion:2.0 描述:SQL Server Provider

Name : TfsBPAPowerShellSnapIn PSVersion : 2.0 Description : This is a PowerShell snap-in that includes Team Foundation Server cmdlets.名称:TfsBPAPowerShellSnapIn PSVersion:2.0 描述:这是一个包含 Team Foundation Server cmdlet 的 PowerShell 管理单元。

Name : WDeploySnapin3.0 PSVersion : 2.0 Description : This is a PowerShell snap-in that contains cmdlets for managing Microsoft Web Deployment infrastructure.名称:WDeploySnapin3.0 PSVersion:2.0 描述:这是一个 PowerShell 管理单元,包含用于管理 Microsoft Web 部署基础结构的 cmdlet。

SOLVED!解决了!

Apparently TFPT Query engine 2010 uses some sort of old exe file that could only be found in显然 TFPT 查询引擎 2010 使用了某种只能在

https://marketplace.visualstudio.com/items?itemName=MartinWoodward.TeamFoundationServerPowerToolsDecember2011 https://marketplace.visualstudio.com/items?itemName=MartinWoodward.TeamFoundationServerPowerToolsDecember2011

Step 1: run in ISE the following:第 1 步:在 ISE 中运行以下命令:

notepad $PROFILE

This will open your PowerShell profile script.这将打开您的 PowerShell 配置文件脚本。 If the file doesn't exist, it will prompt you to create it.如果文件不存在,它会提示您创建它。

Step 2: Add following lines (amke sure files do exist first if you using different version of VS!)第 2 步:添加以下行(如果您使用不同版本的 VS,请确保文件确实存在!)

Set-Alias tfpt "C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools\tfpt.exe"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Powershell - 术语“=”未被识别为 cmdlet 的名称 - Powershell - The term '=' is not recognized as the name of a cmdlet PowerShell,术语“xxxxxx”未被识别为 cmdlet 的名称 - PowerShell, The term 'xxxxxx' is not recognized as the name of a cmdlet PowerShell参数-“术语'param'不被识别为cmdlet的名称” - PowerShell parameters - “The term 'param' is not recognized as the name of a cmdlet” 无法将术语“ EXEC”识别为cmdlet Powershell的名称 - The term 'EXEC' is not recognized as the name of a cmdlet Powershell 术语''不被识别为cmdlet的名称 - Term ' ' is not recognized as the name of a cmdlet 术语''不被识别为cmdlet的名称, - The term ' ' is not recognized as the name of a cmdlet, 未将术语“搜索邮箱”识别为cmdlet Exchange Online Powershell的名称 - The term 'Search-Mailbox' is not recognized as the name of a cmdlet Exchange Online Powershell Powershell Runbook - 术语“Get-AzureRMWebAppSlot”未被识别为 cmdlet 的名称 - Powershell Runbook - The term 'Get-AzureRMWebAppSlot' is not recognized as the name of a cmdlet Powershell错误“术语'Get-SPWeb'未被识别为cmdlet的名称,函数......” - Powershell Error “The term 'Get-SPWeb' is not recognized as the name of a cmdlet, function…” Azure PowerShell - Invoke-AzContainerInstanceCommand - 术语“进程”未被识别为 cmdlet 的名称 - Azure PowerShell - Invoke-AzContainerInstanceCommand - The term 'processÂ' is not recognized as the name of a cmdlet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM