How to use a Module with Release Management


I wrote a module to deal with permissions that need to be set for an application when it is being installed.

This module does the following things:
1. adds permissions
2. removes permissions
3. has specific functions to call specific permission adds.

With that in mind I struggled with how to utilize my new Powershell Module. Release management has this notion of Actions and Tools.

I discovered by trial and error that tools are copied to the machine and you can attach a script to the tool. So what I’m going to do now is show you the steps I took to get to the end result. 2016-02-08 14_39_00-Clipboard

Now in the tool I can add my script:

2016-02-08 14_42_16-Release Management Client for Visual Studio 2015

Now since I have my tool in place I can now add an action:

2016-02-08 14_45_42-Release Management Client for Visual Studio 2015.jpg

In my action I can now call my function that is in the tool:

2016-02-08 14_46_52-Release Management Client for Visual Studio 2015

The tricky part is figuring out the right way to put the commandline parameters in.

The best way I’ve found to model the usage of your scripts is to go to the Powershell prompt and launch exactly the same way that Release management does.

After much trial and error and gnashing of teeth I found that declaring the variables first before calling the invoke command seemed to work the best.

2016-02-08 15_01_19-Windows PowerShell 5.0.10586.51 (phcorp_tschumacher)

I kept plugging along till I found the command in the Action to work as I wished it to:

$p = '__path__' ; $u = '__username__';  invoke-command { import-module  .\myModule-ntfs.psm1; Add-ServicePermissions -username $u -path $p }

Now that I have my Action built I can call the action from my Release Template and give it the two params I provided in the script sample above:

UserName

Path2016-02-08 15_05_47-Release Management Client for Visual Studio 2015

 
Now I get the behavior I want and the automation around scripted credential Adds.

 

Until then keep scripting.

 

Advertisement

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 )

Facebook photo

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

Connecting to %s