Recently I have been working on my new module AzurePipelinesPS. It is open source on GitHub and published to the Powershell Gallery via Azure DevOps. If you are unfamiliar with Azure DevOps take a minute to browse through the microsoft introduction.

Why Azure DevOps Pipelines

I have been working with Team Foundation Server for many years as part of my day job as well as for my personal repositories. Working within the UI can be cumbersome and time-consuming. Making bulk changes and programmatically creating builds from the command line is something I knew I would use often. I also wanted to share the module with the rest of you to give back to all the GitHub users who have helped me over the years! Allow me to introduce you to some commands that make my day as a DevOps Engineer much easier.

Installing AzurePipelinesPS

Installing the module from the Powershell Gallery is easy.

Install-Module AzurePipelinesPS

Creating a New Build

Now that we have the module installed we can start creating builds from the command line.

$secureToken = ConvertTo-SecureString -String 'myToken' -AsPlainText -Force New-APBuild -Instance 'https://dev.azure.com/' -Collection 'michaeldejulia' -Project 'AzurePipelinesPS' -PersonalAccessToken $secureToken -ApiVersion '5.0-preview.4' -Name 'AzurePipelinesPS'

That was pretty neat, however the idea was to make things easier. Typing out parameters like that over and over again is not what I call easy. That’s why I implemented AzurePipelinesPS sessions.

AzurePipelinesPS Sessions

AzurePipelinesPS session support saves a set of parameters in memory or persits them to disk for later use. Personal Access Tokens are stored securely so you do not have to worry about saving them in a credential manager or converting it to a secure string in order to run a command.

Creating a Session

$splat = @{ Collection = 'myCollection' Project = 'myProject' Instance = 'https://dev.azure.com/' PersonalAccessToken = 'myPersonalAccessToken' Version = 'vNext' SessionName = 'mySession' } New-APSession @splat

Saving a Session

Saved session data will persist on disk, it can be retrieved by Get-APSession.

$sessions = Get-APSession $sessions | Save-APSession

Removing a Session

Removing a session is easy, just pipe the session to Remove-APSession.

$sessions = Get-APSession $sessions | Remove-APSession

Getting a Build with a Session

Using the build Id from the build we just created and the session that we just saved, I can retrieve the builds details and see that it completed successfully.

$session = Get-APSession -SessionName 'MDAzure' Get-APBuild -Session $session -BuildId 88

How can I Contribute

There are hundereds, possibly thousands of endpoints that do not yet have powershell functions, please feel free to contribute to the module here and tell your friends!