1
votes

I have installed Team foundation power tool to Jenkins server. I have TFS 2015 installed with Full VS 2015. I want to run powershell script which pull project from TFS. I am able to run it from Jenkins server. When i try to pass that script from Jenkins build definition using powershell plugin. I am getting errors regarding Team foundation power tool. Jenkins is complaining that team foundation power tool is not installed. I tried to uninstall and reinstall tool. My Jenkins service is running under same by using which i installed this tool. Also, this tool is not user specific. It's installed for all users. can someone please help?

Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.TeamFoundation.PowerShell' is not installed on this computer. At C:\Users\AppData\Local\Temp\jenkins4325377511943060199.ps1:22 char:1 + Add-PSSnapin Microsoft.TeamFoundation.PowerShell + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (Microsoft.TeamFoundation.PowerShell:String) [Add-PSSnapin], PSArgument Exception + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand Get-TfsChildItem : The term 'Get-TfsChildItem' 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:\Users\AppData\Local\Temp\jenkins4325377511943060199.ps1:25 char:10 + $items = Get-TfsChildItem $AutoDeployDir -Recurse -Server $tfsCollection + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-TfsChildItem:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

enter image description here as you can see, I can run it manually inside the server.

2
Did it work if you manually run the powershell script on Jenkins server?PatrickLu-MSFT
Yes, it worked perfectly. So, I am confused what it can be? I just updated errors in questions. It's saying in first line "Add-PSSnapin: The Windows PowerShell snap-in 'Microsoft.TeamFoundation.PowerShell' is not installed on this computer."Meet101

2 Answers

1
votes

According to the error

Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.TeamFoundation.PowerShell' is not installed on this computer.

May the TFS Powertools is not installed fully. By default it doesn’t install the PS CmdLets.

enter image description here

So, simple add that during the reinstallation and then try the build with Jenkins again.

enter image description here

More ways please refer this similar question: TFS Build: `Microsoft.TeamFoundation.PowerShell' is not installed on this computer

0
votes

I figured it out. It's an issue with tool between x32 and x64. You will need to add registry to fix this issue. copy below content in *.reg file and double click on file to install it to registry.

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.TeamFoundation.PowerShell] "PowerShellVersion"="4.0" "Vendor"="Microsoft Corporation" "Description"="This is a PowerShell snap-in that includes the Team Foundation Server cmdlets." "VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft" "DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,This is a PowerShell snap-in that includes the Team Foundation Server cmdlets." "Version"="14.0.0.0" "ApplicationBase"="C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools" "AssemblyName"="Microsoft.TeamFoundation.PowerTools.PowerShell, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" "ModuleName"="C:\Program Files (x86)\Microsoft Team Foundation Server 2015 Power Tools\Microsoft.TeamFoundation.PowerTools.PowerShell.dll" "CustomPSSnapInType"="Microsoft.TeamFoundation.PowerTools.PowerShell.TFPSSnapIn"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.TeamFoundation.PowerShell] "PowerShellVersion"="4.0" "Vendor"="Microsoft Corporation" "Description"="This is a PowerShell snap-in that includes the Team Foundation Server cmdlets." "VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft" "DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,This is a PowerShell snap-in that includes the Team Foundation Server cmdlets." "Version"="14.0.0.0" "ApplicationBase"="C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools" "AssemblyName"="Microsoft.TeamFoundation.PowerTools.PowerShell, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" "ModuleName"="C:\Program Files (x86)\Microsoft Team Foundation Server 2015 Power Tools\Microsoft.TeamFoundation.PowerTools.PowerShell.dll" "CustomPSSnapInType"="Microsoft.TeamFoundation.PowerTools.PowerShell.TFPSSnapIn"

Don't forget to change PowerShellVersion and TFS Version based on your setup. It won't work if there is a version mismatch. I found it from http://www.it1me.com/it-answers?id=35292971&ttl=TFS+Build%3A+%60Microsoft.TeamFoundation.PowerShell%26%2339%3B+is+not+installed+on+this+computer