VSTS Powershell Commands

Tips and tricks Inline Powershell task VSTS, in this post VSTS/TFS command you can trigger from Powershell in your build or release pipeline

Maximize how you use your VSTS build and release pipeline with Inline Powershell tasks. In this blog series ‘Tips and Tricks for Inline Powershell’, I will show simple samples on how to get more out of your pipelines. This blog post: VSTS Powershell Commands.

VSTS Inline Powershell task
The Inline PowerShell VSTS task enables you to execute PowerShell from a textbox within your build or release pipeline. You can run a PowerShell script on you agent or as Azure Powershell.
Introduction Inline Powershell Task
Install Inline Powershell Task

VSTS Powershell Commands
From Powershell you are able to send commands to VSTS as you have seen in the earlier tips and tricks. This post gives an overview of availible commands. You have 3 areas you can send a command to: task, build and artifact. The general format format for the commands is:

##vso[area.action property1=value;property2=value;...]message

Area Task
The logissue action logs an error or warning to logging timeline of the task. The issue is reported in the build overview and the logs.

##vso[task.logissuetype=error;sourcepath=consoleapp/main.cs;linenumber=1;columnnumber=1;code=100;]this is an error


Logdetail records are shown in the timeline of the task.

Write-Host "##vso[task.logdetail id=3ce154f2-6ac5-493b-8737-045f9bcb208b;name=project1;type=build;order=6]create new timeline record"
Write-Host "##vso[task.logdetail id=3ce154f2-6ac5-493b-8737-045f9bcb208c;parentid=3ce154f2-6ac5-493b-8737-045f9bcb208b;name=project1;type=build;order=7]create new timeline record2"
Write-Host "##vso[task.logdetail id=3ce154f2-6ac5-493b-8737-045f9bcb208b;progress=100;state=Complete;]update timeline record"


Uploads a file to the current timeline record in the task. You will be able to access the file later from the timeline.

##vso[task.addattachment type=myattachmenttype;name=myattachmentname;]c:\myattachment.txt

Upload a summary to the current timeline record in the task.


Upload a log file to the logs. This can be used to upload the logs from a command that executed.


Set the progress of the task. The progess will be updated when you monitor the task. Read more…

For ($i=0; $i -lt 100; $i++) {
    Write-Output "##vso[task.setprogress value=$i;]Log ouput"
    Start-Sleep -s 1


You can set the outcome of the task. With this you can change the flow of your pipeline. Read more…

##vso[task.complete result=Succeeded;]DONE

With setvariable you can set variable for later use. Read more…

##vso[task.setvariable variable=testvar;]testvalue

You can set an endpoint for later usage with setendpoint

##vso[task.setendpoint id=000-0000-0000;field=authParameter;key=AccessToken]testvalue

Area Artifact
Create a artifact link in your build.

##vso[artifact.associate type=filepath;artifactname=MyFileShareDrop]\\MyShare\MyDropLocation

Upload an artifact in your project.

##vso[artifact.upload containerfolder=testresult;artifactname=uploadedresult;]c:\testresult.trx

Area Build
Upload interesting logs to the ‘logs\tool’ container


Update the build number of your current build.


Add tags to your build.


More tips and tricks
Use VSTS variables
Let your task fail
Set progress
Change buildnumber
VSTS Command overview
Call a WebHook
Download a file
Install a Powershell Module
Navigate VSTS as filesystem
Make VSTS API Rest calls
Script example: Act on failed build

Git hub command documentation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.