PowerShell Cmdlets for Team Foundation Server and Visual Studio Team Services
Clone or download
igoravl Releases/1.0.0 beta.1 (#69)
* Move Visual Studio detection logic to vswhere.exe

* Fix author name in Wix project

* Fix breaking change in Web API

Change namespace for class TeamProjectReference

* Fix Wix target folder for PS module

* Simplify VSTS build number logic

* Streamline interactive connections

Add the -Interactive switch

* Remove extra leading spaces from comments

* Fix paths in debug script

* Change version metadata logic

Use number of days between project creation in GitHub (2014-10-24) and today to increment version metadata

* Fix merge conflicts

* Resolve conflict

* Add verbose comments
Latest commit ab1fd61 Apr 6, 2017



PowerShell Cmdlets for Team Foundation Server and Visual Studio Team Services

Whats is TfsCmdlets?

TfsCmdlets is a PowerShell module which provides many commands ("cmdlets" in PowerShell parlance) to simplify automated interaction with Team Foundation Server and Visual Studio Team Services.

By using TfsCmdlets, TFS administrators (even power users) can create scripts to automate many different tasks, ranging from retrieving work items to create new team project collections.

TfsCmdlets is available in many formats. The full (MSI-based) installer also includes Team Foundation Server Shell, a PowerShell window pre-configured to make interacting with TFS via command line a joy!

Team Foundation Server Shell

Quick start guide

Firstly, download and configure the latest version of the Visual Studio ALM Virtual Machine (a.k.a "Brian Keller VM") in your computer in order to have a sandbox to play with.

Next, install TfsCmdlets inside the virtual machine (see section "How to install", below), open a PowerShell window and try the following commands:

# Connect to the FabrikamFiber team project collection
# (Will be used as default for the -Collection argument when required by a cmdlet)
Connect-TfsTeamProjectCollection http://vsalm:8080/tfs/FabrikamFiberCollection

# Get a list of team projects in the currently connected TPC

# List the existing iterations in the FabrikamFiber team project
Get-TfsIteration -Project FabrikamFiber

# Connect to the FabrikamFiber team project
# (will be used as default for the -Project argument when required by a cmdlet)
Connect-TfsTeamProject FabrikamFiber

# Create a new iteration
New-TfsIteration 'Release 3'

# Get all bugs in the current team project
Get-TfsWorkItem -Filter '[System.WorkItemType] = "Bug"'

# Create a new PBI in the 'Release 3' iteration
New-TfsWorkItem -Title 'New product backlog item' -Type 'Product Backlog Item' -Fields @{'System.IterationPath'='Release 3'}

How to install

TfsCmdlets can be obtained from many different sources and in many different formats. Choose the one most suitable to you!

PowerShell Gallery

If you're using Windows 10, Windows Server 2016 or installed Windows Management Framework 5 then the simplest way to install TfsCmdlets is via PowerShell Gallery.

Open an elevated PowerShell prompt and type:

Install-Module TfsCmdlets

Additional information


Using Chocolatey? Then open an elevated PowerShell prompt and type:

# To install the latest pre-release (alpha, beta) version of TfsCmdlets, type:
choco install TfsCmdlets -pre

# To install the latest final release version of TfsCmdlets, type:
choco install TfsCmdlets


Nuget is a great option if you need to integrate TfsCmdlets with your continuous integration process (e.g. you need to create a TFS work item during the execution of an automated build).

To add TfsCmdlets to your solution, search for TfsCmdlets in the Visual Studio "Manage Nuget packages for solution..." dialog.

  • Note: To add the latest pre-release version of TfsCmdlets, don't forget check the "Include prerelease" checkbox

Additional information

Offline installation

When the target machine is not connected to the internet, none of the options above are available. In that case, your best bet is one of the offline installation alternatives below.

You can get one of the offline installers listed below from the GitHub Releases page.

Full installer (MSI-based)

The full installer will install the module files to the Program Files folder in your computer, make the module available to PowerShell and create the Team Foundation Server Shell icon in the Start Menu.

To install the full installer:

  • Download the MSI file from the Releases page;
  • Open the downloaded MSI file
    • NOTE: If Windows SmartScreen flags the file as insecure and refuses to run it, you can click the "More info" button/link in the dialog and select the "Run anyway" option.

To uninstall the full installer:

  • Use the Programs and Features (formerly "Add and remove programs") function in the Windows Control Panel.

Portable installer

The portable installer is a zip file containing all the required the module files.

To install the portable installer:

  • Download the zip file from the Releases page;
  • Open your Documents folder in Windows, then open the WindowsPowerShell folder in it;
  • Inside the WindowsPowerShell folder, create a new folder called Modules in it (if missing) and then create a new folder called TfsCmdlets in Modules;
  • Extract the contents of the zip file to the TfsCmdlets folder.

You must end up with a folder structure similar to [Documents]\WindowsPowerShell\Modules\TfsCmdlets. Files such as TfsCmdlets.psd1 must be located in the TfsCmdlets folder.

To test the installation, open a new PowerShell window and type:

Import-Module TfsCmdlets

To uninstall the portable installer

  • Close all PowerShell windows where you were using TfsCmdlets (to free files in use);
  • Delete the TfsCmdlets folder from the [Documents]\WindowsPowerShell\Modules folder.

Contribution Guidelines

Coming soon.

Additional Information

[Build status Issues Forks Stars GitHub license NuGet Chocolatey GitHub release Twitter