powershelltfs

How to install PowerShell commandlets for TFS on a machine with Visual Studio 2017


I have some PowerShell scripts that work with TFS. I used to have a Visual Studio 2015 with PowerTools installed, so that was working fine.

I now have a new machine with Visual Studio 2017 and I cannot install commandlets using PowerTools deployment. What are my options?

Installing VS 2015 is not an option for me (also, not a long-term solution).

I have tried:

Add-PSSnapin Microsoft.TeamFoundation.PowerShell

but getting an error that Microsoft.TeamFoundation.PowerShell is not installed. Trying to install it, get an error that module was not found.

 Install-Module  Microsoft.TeamFoundation.PowerShell

Is there any way to install this without installing VS 2015?


Solution

  • You can install only the TFS Power Tools cmdlets without VS 2015 with Chocolatey:

    1. Open PowerShell.
    2. Chocolatey - Must be present on the machine, if you don't have it run this:

      Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

    3. Download the TFS Power Tools installer: Invoke-WebRequest -OutFile Install-TFPT.ps1 https://gist.githubusercontent.com/jrotello/2b9cd552e764e1cf364a3535b1dcc315/raw/Install-TFPT.ps1

    4. Install the PowerShell cmdlets: ./Install-TFPT.ps1 -InstallDirectory <installPath>

    5. Once the install script has been successfully executed you can use the following command to load the PowerShell Snapin into your session, or add the command to your PowerShell profile so the snapin is loaded into each PowerShell session you create. Add-PSSnapin Microsoft.TeamFoundation.PowerShell

    Another way you can find here.

    In addition, you can download another TFS PowerShell module of Leon Jalfon with many useful commands:

    https://github.com/leonjalfon1/tfs-powershell-module