In TFS 2015 build system, running a PowerShell script stored in source code is simple because there is a dedicated action to accomplish this task, but if you want to run a PowerShell script that is not in source control, you have no option out of the Box.
Thanks to Update 2, you have now the ability to use the extensions you can find on Visual Studio Marketplace directly in your on-premise TFS installation. In the Upper Right corner of Web Ui you can find an icon that link to
Figure 1: Link to manage extensions
This opens an administration page that allows you to manage extensions of your TFS installation. The first time you open this page, you will see no extension installed, so it is time to browse Visual Studio MarketPlace to find an extension. Actually I want to run inline PowerShell and I can immediately find that there is an extension that can solve my need.
As you can see from Figure 2, this extension have a couple of button, the first one, Install, is used to install this extension on one of your VSTS account, but if the extension is compatible with on-premise TFS you have also the option to Download the extension.
Figure 2: Once you find an extension compatible with on-premise TFS you can download it.
The extension is a simple .vsix file, and from extension administration page you can upload to your TFS.
Figure 3: Once downloaded you can upload the extension to your TFS.
The process of uploading is really simple:
Figure 4: Browse for downloaded extension
Figure 5: Upload UI shows all the detail of the file
Now you can press Upload button, and the extension is uploaded to TFS and ready to be activated.
Figure 6: Uploaded extension is now listed in the list of available extension
- Figure 7: Install the extension on one or more collection
The concept behind “install then activate” is that, once uploaded the extension is available for the TFS Server instance, but then you should install in each Project Collection where you want to use that extension.
Figure 8: Choose the collection you want to install the extension into
Figure 9: Confirm the selection
Once the Extension is installed in one Project Collection it can be used. In this example the extension contains a new build Task that allows you to execute an arbitrary PowerShell script during the build. To verify that everything is ok you can create a build and verify that the new Task is available and ready to use.
Figure 10: The extension is ready and can be used
Thanks to TFS 2015 Update 2 you can Download and install extension for VSTS Marketplace to your on-premise TFS installation with few clicks.