PowerShell Studio 2014: Editing Functions

We improved the Function Builder yet again!

Man, when are you guys going to stop this?

Never.

With the 4.1.71 build of PowerShell Studio 2014, you now have the option to edit existing functions within the Function Builder!

Ok cool, how do I edit my existing functions?

Simple, you can edit existing functions using the following methods:

1. Using the new Functions menu in the updated ribbon:

image

2. Use the editor’s context menu:

image

3. Press (Ctrl + Shift + Alt+ E) using the keyboard.

4. Use the Functions explorer:

We added a toolbar to the Function Builder so you can insert a new function or edit the selected function.

image

Now let’s look at the updated Function Builder:

SNAGHTML5a1823

The first thing you will notice is that the fields are pre-populated with the existing function’s information. Updating a function is now easier than ever, especially when dealing with complex parameter sets. In addition, we updated some of the help messages to better explain the fields.

Next we updated the Parameter editor dialog:

SNAGHTML5f57b2

You now have the option to add a new Parameter Set within the Parameter editor:

image

You can now specify a default value for the parameter:

image

When the parameter is set to Mandatory the default value field is disabled.

Once you are satisfied with your changes to the function, the Function Builder will update the definition as well as its comment-based help if help information is available (see below).

 

Special Considerations:

– Renaming Functions

When you rename an existing function in the Function Builder, PowerShell Studio will bring up the Preview Changes dialog:

SNAGHTML720e54

Here you have the option to select which of the function references you wish to update in the script.

-Renaming Parameters

Build v4.1.71 will not update references to renamed parameters.

If you want to rename parameters use the Rename Refactoring instead. Rename Refactoring will ensure your references and their definitions are up-to-date without breaking your script.

http://www.sapien.com/blog/2014/05/01/powershell-studio-2014-rename-refactoring/

The next service build (v4.1.72 and above) will support parameter reference updating.

– Comment-Based Help

The Function Builder will now insert a Comment-Based help block only if you fill in a help field in the Function Builder. This includes all the Description and Synopsis fields.

– Comments in the Parameter Block

If the Function Builder encounters any comments in the function’s parameter block it will automatically assign the comment to the parameter’s description. All parameter comments will be moved to the comment-based help block.

– Name Validation

The Function Builder will now validate the function’s name to prevent duplicates.

– Undo changes

If you are not happy with the changes made by the Function Builder for any reason, you can always undo the changes directly in the editor (Ctrl + Z).

 

We are constantly striving to make PowerShell Studio 2014 the best tool out there. Please let us know what you think by posting on our forums. Your feedback is important to us.