Запуск локально на моем клиенте (не на сервере TFS) Windows 10 pro рабочая станция и получение ошибки. Что мне не хватает?
> 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
Пример кода ниже
# 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
}
}
Инструменты: PowerShell ISE, TFS Server 2012, Windows PowerShell 2.0 Engine, а также установлены: C: \ Program Files (x86 ) \ Электроинструменты Microsoft Team Foundation Server 2012 C: \ Program Files (x86) \ Электроинструменты Microsoft Team Foundation Server 2013 C: \ Program Files (x86) \ Электроинструменты Microsoft Team Foundation Server 2015
> Get-Host | Select-Object Version >> Version
> -------
> 5.1.17763.1007
Попытка выполнить команду:
powershell -Command get-pssnapin -Registered
РЕЗУЛЬТАТ:
Имя: SqlServerCmdletSnapin100 PSVersion: 2.0 Описание: Это оснастка PowerShell, включающая различные SQL командлеты сервера .
Имя: SqlServerProviderSnapin100 PSVersion: 2.0 Описание: SQL Поставщик сервера
Имя: TfsBPAPowerShellSnapIn PSVersion: 2.0 Описание: Это оснастка PowerShell, включающая командлеты Team Foundation Server.
Имя: WDeploySnapin3.0 PSVersion: 2.0 Описание: это оснастка PowerShell, содержащая командлеты для управления Microsoft Web Deploy инфраструктура.