21

I have installed TFS Power Tools and I am trying to use the powershell snapin, but I can't figure out how to set it up. When I look in the install folder, I only see the following 5 dlls.

Microsoft.TeamFoundation.PowerToys.Client.dll
Microsoft.TeamFoundation.PowerToys.Common.dll
Microsoft.TeamFoundation.PowerToys.Controls.dll
Microsoft.VisualStudio.TeamFoundation.PowerToys.Common.dll
Microsoft.VisualStudio.TeamFoundation.PowerToys.dll

I used instalutil to install each one, and then I used the folowing ps code to see what cmdlets where installed so I could add the snapin but it looks like only a handfull exist in those dlls and these commands are not useful to me right now.

PS H:\> get-pssnapin -registered


Name        : TfsBPAPowerShellSnapIn
PSVersion   : 1.0
Description : This is a PowerShell snap-in that includes Team Foundation Server cmdlets.



PS H:\> get-command -pssnapin TfsBPAPowerShellSnapIn

    CommandType     Name                                                Definition
    -----------     ----                                                ----------
    Cmdlet          Get-MsiProductId                                    Get-MsiProductId [[-ProductIndex] <Int32>] [[-Mo...
    Cmdlet          Get-TfsDBServer                                     Get-TfsDBServer [[-DBPath] <String>] [-Verbose] ...
    Cmdlet          Get-TfsHealthPing                                   Get-TfsHealthPing [-Verbose] [-Debug] [-ErrorAct...
    Cmdlet          Get-TfsSqlData                                      Get-TfsSqlData [[-ConnectionBuilder] <SqlConnect...

thanks.

stimms
  • 42,945
  • 30
  • 96
  • 149
TheSean
  • 4,516
  • 7
  • 40
  • 50
  • How can I use TFS cmdlets, now (2015) in Powershell ? – Kiquenet May 04 '15 at 13:33
  • @Kiquenet Make sure that you select the cmdlets during installation of the Power Tools. The 2013 version seems to support PowerShell x64, but not PowerShell x86. – user247702 May 08 '15 at 08:48

4 Answers4

37

Any chance you are running on x64? On my x64 system the Microsoft.TeamFoundation.PowerShell snapin only shows up under the x86 flavor of PowerShell. Adding it as simple as:

PS> Add-PSSnapin Microsoft.TeamFoundation.PowerShell

I take it that you installed TF Power Tools October 2008 release. If so, then there is also a shortcut on the start menu for a PowerShell console file that you can fire up. That preloads the TF snapin.

  • I agree x64 is the most likely reason. You shouldn't need to run installutil at all -- the Power Tools installer does it for you (along with enabling local script execution, if you choose). – Richard Berg Jun 27 '09 at 21:19
  • This method failed for me running PowerShell 2 on Windows Server 2008 R2. I get: Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2. At line:1 char:13 + Add-PSSnapin <<<< Microsoft.TeamFoundation.PowerShell + CategoryInfo : InvalidArgument: (Microsoft.TeamFoundation.PowerShell:String) [Add-PSSnapin], PSArgument Exception + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand Any idea why? – urig Jan 11 '10 at 09:58
  • 16
    In the latest version of the power tools (March 2011 as of this comment), the powershell cmdlets aren't installed with the standard installation. You have to choose the custom installation and set the powershell stuff to be installed. – sdanna Aug 04 '11 at 20:43
  • 1
    Why is there so much frustration between the x86/x64 console and installs like this? Is it powershell's fault? The specific installer? – Anthony Mastrean Nov 07 '11 at 17:30
  • In the December 2011 version of the power tools, there is no custom option, but it does appear to install correctly for the PowerShell x86 only. – 15ee8f99-57ff-4f92-890c-b56153 Dec 09 '13 at 19:16
  • For the 2013 version, it seems to be the other way around. The snapin is available for PowerShell x64, but not for PowerShell x86. – user247702 May 08 '15 at 08:47
13

While installing Visual Studio Team Foundation Server 2013 Update 2 Power Tools .msi, I found that I had to re-install and select Modify installation and enable the installation of PowerShell Cmdlets .

Philip Beck
  • 375
  • 2
  • 10
  • 4
    For me, I actually had to Repair my installation. Took a while too... it appeared like it was hung. But it fixed it. – JamesQMurphy Apr 08 '15 at 20:42
  • 1
    I tried re-install > Modify, no luck. The only program feature available is Best Practices Analyzer. – Rubio May 24 '17 at 11:36
2

@Keith Hill's and @Blakomen's answers are both correct; this and more information is available in the help file.

Start/All Programs/Microsoft Team Foundation Server 2010 Power Tools/Help Windows PowerShell Cmdlets for Visual Studio Team System Team Foundation Server

Or simply

C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools\Help\PowerShellCmdlets.mht

(Adjust as necessary for your install folder and version of Power Tools)

Note the following (from help Get-TfsItemHistory -full):

-Server <TeamFoundationServer>
    Identifies the Team Foundation Server. This option is required if the command
    is invoked from a directory that is not mapped to a workspace.
TrueWill
  • 25,132
  • 10
  • 101
  • 150
0

If you haven't used PowerShell at all yet, you may need to enable the execution of remote scripts to get the PowerShell console in the TF Power Tools Oct 2008 release to work. Open up a Powershell console and type in:

Set-ExecutionPolicy RemoteSigned
Henry C
  • 4,781
  • 4
  • 43
  • 83
  • 3
    You'll want to do that in a PowerShell instance that was launched with administrative privileges. – Rytmis May 03 '10 at 19:21