Share via


VS 2013 Release Management: Create Tool & Action to Run Custom PowerShell Scripts in Deployment Agent

Can a custom PowerShell script run in Release Management Deployment Agent? 

One way is to create a PowerShell script and add it as a resource and create a tool and an action in Release Management Inventory. This is more suitable for adding a generic tool. But if it is required to run a custom PowerShell script specific to a given release template, copied to deployment machine from the build drop, is it possible? Out of the box set of tools and actions in Release Management Server do not support this. This can be done by creating a generic tool and an action.

Let's  see how to do this step by step.

In Release Management Client go to Inventory tab Tools, click on New.

http://lh3.ggpht.com/-XZTHimvcYHY/U9PgO3042HI/AAAAAAAACkQ/D5oG9j9i5YA/001_thumb%25255B2%25255D.png?imgmax=800

For the execution command type “powershell” and for the arguments type

-command __ScriptToExecute__  __Arguments__

This will add two parameters in the tool “ScriptToExecute” and “Arguments”. Provide a suitable Name and a Description as well.

http://lh6.ggpht.com/-R8TkfxiiQj0/U9Ps_zabwbI/AAAAAAAACoI/4POd4w-6qT0/002_thumb%25255B3%25255D.png?imgmax=800

Click on Save & Close to add the new tool.

http://lh6.ggpht.com/-hs3IeVGsSwU/U9PufKoOssI/AAAAAAAACoY/iZj7a_-3cgc/003_thumb%25255B2%25255D.png?imgmax=800

Go to Actions and click on New to add new action.

http://lh5.ggpht.com/-iQslqljnU9E/U9Puhb3ADaI/AAAAAAAACoo/ya6KulDbnvA/004_thumb%25255B3%25255D.png?imgmax=800

Select the tool created and add a new Category for Custom Actions. Fill the Name and Description.v http://lh5.ggpht.com/-bpAzKmA29KY/U9PukUMgwSI/AAAAAAAACpA/AKH3maoQDkQ/005_thumb%25255B2%25255D.png?imgmax=800

Save to create the new Action.

http://lh6.ggpht.com/-AwrQrGx6FgM/U9Pumt1MbDI/AAAAAAAACpQ/1xGXB0EYSiA/006_thumb%25255B3%25255D.png?imgmax=800

 http://lh3.ggpht.com/-74tvQ41qZpg/U9Pupi7RSVI/AAAAAAAACpo/Y6I4rPbknhs/007_thumb%25255B3%25255D.png?imgmax=800

To test Tool and Action in action create a very simple PowerShell script like below.

http://lh5.ggpht.com/--Q9OSYU6k2A/U9PusJ1ZATI/AAAAAAAACqA/StXEQnBbXhI/008_thumb%25255B3%25255D.png?imgmax=800

In a test release template new custom action is available.

http://lh3.ggpht.com/-8LlYH2OPWrk/U9PuvMKnnWI/AAAAAAAACqg/eJ3TErtTTHY/009_thumb%25255B4%25255D.png?imgmax=800

Fill the script name with the path and arguments(for testing purpose script copied manually to deployment machine, this can be a script downloaded to deployment machine from the build drop using an XCOPY action in the release template).

http://lh4.ggpht.com/-azsVo_PIR4I/U9PuxQgnnOI/AAAAAAAACqw/mvkrGynAOJw/010_thumb%25255B3%25255D.png?imgmax=800

Save the release template and click New Release to test. This example does not use a build out put, but the action can be used with a template bound to a build drop as well, as a matter of fact it can be used with any release template.

http://lh5.ggpht.com/-vMRXEd3q_hI/U9Puz-9-00I/AAAAAAAACrI/fzKKtX7gBxc/011_thumb%25255B3%25255D.png?imgmax=800 

Start the release by clicking on Start.

http://lh3.ggpht.com/-t5ea_epvpP0/U9Pu2dpKjVI/AAAAAAAACrg/f0IdXVg0b8o/012_thumb%25255B2%25255D.png?imgmax=800

Script execution succeeded.

http://lh4.ggpht.com/-6tz2y-27dXs/U9Pu5SSb4KI/AAAAAAAACr4/fi_PamStySk/013_thumb%25255B2%25255D.png?imgmax=800

Click on View Log to see the output from script.

http://lh3.ggpht.com/-42esjGACbP8/U9Pu7hAtFtI/AAAAAAAACsQ/7cZIH_0U-sE/014_thumb%25255B2%25255D.png?imgmax=800