Git Product home page Git Product logo

tfscmdlets's Introduction

TfsCmdlets: PowerShell Cmdlets for Azure DevOps and Team Foundation Server

GitHub license Build status GitHub release Issues Forks Stars

PowerShell Gallery NuGet Chocolatey GitHub all releases

What is TfsCmdlets?

TfsCmdlets is a PowerShell module which provides many commands ("cmdlets" in PowerShell parlance) to simplify automated interaction with Team Foundation Server (2010 to 2018) and Azure DevOps (Server 2019+ and Services).

By using TfsCmdlets, Azure DevOps administrators and/or power users can create scripts to automate many different tasks, ranging from retrieving work items to creating new team project collections.

TfsCmdlets is available in many installation formats. It also includes Azure DevOps Shell, a PowerShell window pre-configured to make interacting with Azure DevOps via command line a joy!

Azure DevOps Shell

Quick start guide

Do you have an Azure DevOps account created? Awesome! If not, you might want to create one.

HINT: Optionally, you may consider to leverage the Azure DevOps Demo Generator to fill a team project with sample data, in order to have a sandbox to play with. The examples below will assume that you created a team project called PartsUnlimited, based on the namesake template available at the Azure DevOps Generator web site.

Next, install TfsCmdlets in your computer (see section "How to install", below), open a PowerShell window and try the following commands:

# Connect to your Azure DevOps organization
# (Will be used as default for the -Collection argument when required by a cmdlet)
Connect-TfsTeamProjectCollection 'https://dev.azure.com/<your_organization_name>'

# Get a list of team projects in the currently connected organization
Get-TfsTeamProject

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

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

# Create a new iteration
New-TfsIteration 'Sprint 7'

# Get all bugs in the current team project
Get-TfsWorkItem -WorkItemType 'Bug'

# Create a new PBI in the 'Sprint 7' iteration
New-TfsWorkItem -Title 'New product backlog item' -Type 'Product Backlog Item' -Iteration 'Sprint 7'

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 later) or have installed Windows Management Framework 5 (or later) then the simplest way to install TfsCmdlets is via PowerShell Gallery.

Open an elevated PowerShell prompt and type:

Install-Module TfsCmdlets

Optionally, you can install it locally in your user profile. That is particularly useful when you can't run as an administrator or don't want to make the module available to all users in the computer:

Install-Module TfsCmdlets -Scope CurrentUser

Package details

Windows Package Manager (winget)

The new Windows Package Manager ("winget") is a command line tool that enables developers to discover, install, upgrade, remove and configure applications on Windows 10 computers. This tool is the client interface to the Windows Package Manager service.

To install TfsCmdlets via winget, open a command prompt and type:

winget install TfsCmdlets

Package details

Chocolatey

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

choco install TfsCmdlets

Package details

Nuget

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

Package details

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 Azure DevOps 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 folder WindowsPowerShell (for PowerShell 5.1) or PowerShell (for PowerShell 6+);
  • Inside the PowerShell 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]\[Windows]PowerShell\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]\[Windows]PowerShell\Modules folder.

Contribution Guidelines

Additional Information

tfscmdlets's People

Contributors

dependabot[bot] avatar igoravl avatar lfraile avatar nenoloje avatar nohwnd avatar tklingert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tfscmdlets's Issues

Connect-TfsTeamProjectCollection additional prompt when authenticating to VSTS (VSO)

Hello, I'm attempting to connect to Visual Studio Team Services (formerly Visual Studio Online) with the following command and Alternate Credentials:

Connect-TfsTeamProjectCollection -Collection "https://.visualstudio.com/DefaultCollection" -Credential $myCred

It prompts me for my username and password (the normal windows dialog) which I enter correctly, then it prompts again (this time using single sign-on UI). The goal is to supply a PS-Credential object which should take care of the first windows credential prompt, however I need to not be prompted a second time. Am I doing something wrong here or is this a bug?

Thanks for any inputs
-sean

Create New-TfsLabel cmdlet

This command will create a new label
Parameters
Collection
LabelName
Owner
ServerFolder

See command: tf label

Add tab completion support for Server, Collection, Project parameters

Server autocomplete should use two data sources:

  • Get-TfsRegisteredConfigurationServer
  • An MRU list mantained by TfsCmdlets itself, which is updated whenever the user connects to a server

Collection autocomplete should use three data sources:

  • Get-TfsRegisteredConfigurationServer
  • An MRU list mantained by TfsCmdlets itself, which is updated whenever the user connects to a server
  • The list of TPCs in the currently connected Configuration Server (if any)

Project autocomplete should use the following data source:

  • The list of projects in the currently connected TPC (if any)

Get-TfsVersion

Create a function that returns the version (including Update level) of a TPC/Config Server

Question : supports of MacOS installation version with .NET Core?

Is this module is intended to be executed on a MacOS with the .NET Core and Powershell installed? My computer is a Mac, and when I try it, I can install it with Nuget.exe and start the command let. But I have an error that it doesn't find the System.Windows.Form namespace, which is not available for the MacOS.

Because the CmdLet is a command line and Powershell application, ant that it call Visual Studio, is there a way to remove the System.Windows.Form to compile a MacOS compatible version?

Create New-TfsShelveset cmdlet

This command will create a new shelveset
Parameters
Collection
ShelvesetName
Comment
Server Folder

See command: tf shelves

Credentials for unattended use

I wanted to script some extractions and reports to Excel which combine results from different TFS projects, and these cmdlets work great. However, I am trying to script them unattended, and am having difficulty getting authentication working on the TFS components.

Similar operations to make credentials for SMTP are working fine in my script:

$TFSsecstr = New-Object -TypeName System.Security.SecureString
$TFSPassword.ToCharArray() | ForEach-Object {$TFSsecstr.AppendChar($_)}

# This is what we use for making SMTP
$TFScred = new-object -typename System.Management.Automation.PSCredential -argumentlist $TFSAccount, $TFSsecstr

# I've also tried this one which is internal to the TFS cmdlets
# $TFScred = Get-TfsCredential -UserName $TFSAccount -Password $TFSsecstr

# Passing the credentials here never works, but using the interactive prompt will
Connect-TfsTeamProjectCollection $Collection # -Credential $TFScred

Code signing

Sign script and installer files using a code signing certificate

Error when importing module twice

When reloading the module, the following exception is thrown:

Add-Type : Cannot add type. The type name 'TfsCmdlets.AssemblyResolver' already exists.
At D:\Projects\Github_Igor\TfsCmdlets\TfsCmdlets\TfsCmdlets\bin\Release\TfsCmdlets\Startup.ps1:9 char:1
+ Add-Type -Language CSharp -TypeDefinition @"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (TfsCmdlets.AssemblyResolver:String) [Add-Type], Exception
    + FullyQualifiedErrorId : TYPE_ALREADY_EXISTS,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type : Cannot add type. The type name 'PSGenericMethods.MethodInvoker' already exists.
At D:\Projects\Github_Igor\TfsCmdlets\TfsCmdlets\TfsCmdlets\bin\Release\TfsCmdlets\ObjectHelper\ObjectHelper.psm1:503 char:1
+ Add-Type -ErrorAction Stop -TypeDefinition @'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (PSGenericMethods.MethodInvoker:String) [Add-Type], Exception
    + FullyQualifiedErrorId : TYPE_ALREADY_EXISTS,Microsoft.PowerShell.Commands.AddTypeCommand

Module startup logic in Startup.ps1 must check whether the assembly resolver was previously loaded and ignore a reload attempt to prevent the error above.

Support for TFS work item links

Parent-Child relationships would be possible using the Powershell containers, which would allow Move and Create-Item, Get-ChildItem, Get-Parent etc.

Other links probably using the "Add-WorkItemLink" and "Remove-WorkItemLink".

Create New-TfsWorkspaceMapping cmdlet

This command will create a mapping folder an existing WorkSpace
Parameters:
ServerFolder
LocalFolder
Collection
WorkSpaceName

This command is based on tf workfold /unmap

Search-TfsWorkItem

Add a new Search-TfsWorkItem that supports the free-text search notation used by in web-based WI search service.

Given the differences in syntax (and the fact that Get-TfsWorkItem already have many different usage scenarios), adding it to a separate cmdlet/function will avoid that Get-TfsWorkItem's syntax gets too convoluted.

Add -Raw parameter to Get-TfsTeamProject

Sometimes it's useful to get "raw" team projects, i.e. those returned by a call to ICss.ListAllProjects(). It's especially useful when there are malformed projects.

In those cases, instead of returning an instance of MS.TFS.WIT.Client.Project, if should return Microsoft.TeamFoundation.Server.ProjectInfo objects.

Create Get-TfsStatus cmdlet

This command will list all files that existing on specific folder
Parameter:
Collection
ServerFolder
WildCard
Status (true - false) - determines if the file is on checkout.

Add build-time dependency detection logic to build script

In order to help new developers to detect build-time dependencies (currently it depends on PoShTools and WiX), the PSake build script should be able to detect whether those tools are installed or not, guiding user in case they're missing.

Create Remove-TfsStatus cmdlet

This command will execute an Undo Checkout operation on a file.
Parameters:
Collection
Source File

Using base command: tf undo

Get-TfsWorkItemChange

A cmdlet to return the changed values from a work item.

Idea: when given a work item as an argument, it should return a map (a collection of PSCustomObject? a hashtable?) with the revision number and another map with the changed fields (and their respective values) in that revision.

Get-TfsTeamProjectMember

List the members (groups or users) of a given Team Project

Should prompt for:

  • Type (User / Group)
  • Filter ("like" on user/group name)
  • Scope (Child / Descendant). Descendant should recursively process group membership

Should return:

  • User/group name
  • List of group a user/group is member of (if -Scope Descendant)

Example use case:

Which team projects is a given user member of?

$user = "John Doe"
Get-TfsTeamProject | ? { Get-TfsTeamProjectMember -Type User -Scope Descendant -Filter $user }

Add -Force to New-TfsArea and New-TfsIteration

Currently both cmdlets create node recursively when presented with a deep path (e.g. 'Area1/Area2/Area3') where some of the parent nodes (either 'Area1' or 'Area2') don't exist.

That's useful, but may lead to incorrect creation of nodes in case of typos. Having -Force gives the user the opportunity to confirm that's the intended behavior.

Support for saved queries

Right now, Get-TfsWorkItem does not support saved queries - only ad-hoc ones.

We need a saved query-aware version of Get-TfsWorkItem and CRUD cmdlets to support saved queries

Copy-TfsWorkItem

Features

  • Should allow copy between different collections/servers;
  • Should copy multiple revisions (All, Latest, First, Single, Range)
  • Should support WIT change
  • Should support field mapping

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.