{"id":7622,"date":"2014-08-27T07:39:00","date_gmt":"2014-08-27T15:39:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=7622"},"modified":"2014-08-28T08:11:38","modified_gmt":"2014-08-28T16:11:38","slug":"powershell-studio-2014-improved-function-builder","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2014\/08\/27\/powershell-studio-2014-improved-function-builder\/","title":{"rendered":"PowerShell Studio 2014: Improved Function Builder"},"content":{"rendered":"<p>In a previous <a href=\"http:\/\/www.sapien.com\/blog\/2014\/04\/24\/powershell-studio-2014-function-builder\/\">article<\/a> we covered the new Function Builder. In the latest service release of PowerShell Studio 2014 (v4.1.64), we improved parameter set support in the Function Builder. <\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/SNAGHTML31bf1a.png\"><img loading=\"lazy\" decoding=\"async\" title=\"SNAGHTML31bf1a\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"SNAGHTML31bf1a\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/SNAGHTML31bf1a_thumb.png\" width=\"644\" height=\"383\"><\/a><\/p>\n<p>As you can see, we altered the ordering of the fields to improve the over-all work flow of the tool.<\/p>\n<p>Notice the question marks? If you hover or click on a question mark, a help message will popup explaining the respective field.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image_thumb.png\" width=\"644\" height=\"109\"><\/a> <\/p>\n<p><strong>Parameter Sets<\/strong><\/p>\n<p>The Parameter Set field has been expanded to include an Output Type. Now you can specify an optional output type for each parameter set you define.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image1.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image_thumb1.png\" width=\"486\" height=\"131\"><\/a> <\/p>\n<p>When a parameter set is defined, the Function Builder reacts accordingly. For example, the Parameter Set Filter is enabled and a Parameter Set column is added to the Parameters list. <\/p>\n<table cellspacing=\"0\" cellpadding=\"2\" width=\"438\" border=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"227\"><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/SNAGHTML356039.png\"><img loading=\"lazy\" decoding=\"async\" title=\"SNAGHTML356039\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"SNAGHTML356039\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/SNAGHTML356039_thumb.png\" width=\"244\" height=\"230\"><\/a><\/td>\n<td valign=\"top\" width=\"209\"><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image2.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image_thumb2.png\" width=\"244\" height=\"231\"><\/a> <\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"227\"><font size=\"2\">(Before a Parameter Set is defined)<\/font><\/td>\n<td valign=\"top\" width=\"209\"><font size=\"2\">(After a Parameter Set is defined)<\/font><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><strong>Parameters<\/strong><\/p>\n<p>The biggest change to the Function Builder is the parameters section. The columns have been reordered to create a better flow when defining parameters.<\/p>\n<p>The Parameter Set column has been changed from a single selection combo box, to a text field where multiple parameter sets can be defined. You can simply type in the name of the parameter set you wish to assign to the parameter:<\/p>\n<p>&nbsp;<img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image3.png\" width=\"256\" height=\"92\"> <\/p>\n<p>You can also define a new parameter set within this field:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/SNAGHTML38c909.png\"><img loading=\"lazy\" decoding=\"async\" title=\"SNAGHTML38c909\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"SNAGHTML38c909\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/SNAGHTML38c909_thumb.png\" width=\"244\" height=\"146\"><\/a><\/p>\n<p>Or assign multiple parameter sets to a single parameter by using a comma separator.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image4.png\" width=\"480\" height=\"51\"> <\/p>\n<p>The <em>Pos<\/em> column is another new addition. This is an optional field where you can quickly define the parameter\u2019s position attribute. By default, the parameter\u2019s position is determined by the ordering of the parameters.<\/p>\n<p>&nbsp;<img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image5.png\" width=\"480\" height=\"92\"> <\/p>\n<p>For parameters that are assigned to multiple parameter sets, you can define each position by using a comma separator. The position values should follow the same ordering as the parameter set assignments.<\/p>\n<p>Of course, you can also assign the parameter\u2019s position and parameter sets using the parameter\u2019s editor dialog by clicking the edit button:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image6.png\" width=\"480\" height=\"49\"> <\/p>\n<p>We updated the Parameter Dialog\u2019s Parameter Set section to allow you to assign multiple parameter sets:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image7.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image_thumb3.png\" width=\"244\" height=\"195\"><\/a><\/p>\n<p>Note that each parameter set has its own respective settings:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image8.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image_thumb4.png\" width=\"244\" height=\"243\"><\/a> <\/p>\n<p><strong><em>Parameter Set Filter<\/em><\/strong><\/p>\n<p>Another new addition to the Parameters section is the Parameter Set Filter.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image9.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image_thumb5.png\" width=\"244\" height=\"145\"><\/a> <\/p>\n<p>The Parameter Set Filter allows you to either show all the parameters, only show the parameters that are not assigned to a parameter set, or only show parameters within a specific parameter set. Selecting a filter other than \u201cShow All\u201d allows you to work within that specific parameter set. <\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image10.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image_thumb6.png\" width=\"244\" height=\"145\"><\/a> <\/p>\n<p>While in this mode, you can use the up and down menu buttons to move or swap the parameter positions. <\/p>\n<p>For your convenience, the position field now only shows the parameter\u2019s position with-in the selected parameter set and no longer lists the other parameter set positions when a filter is applied. <\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image11.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/08\/image_thumb7.png\" width=\"244\" height=\"145\"><\/a><\/p>\n<p>By default (Show All filter) the up and down move button only changes the order in which the parameters are declared in the function.<\/p>\n<p>Note: In the Show All mode, the Mandatory check box refers to the parameter\u2019s first assigned parameter set.&nbsp; <\/p>\n<p>&nbsp;<\/p>\n<p>When a parameter set is declared, the generated function will now include a switch statement to help you differentiate between the parameter sets:<\/p>\n<pre><span style=\"color: #000000\">    <\/span><span style=\"color: #0000ff\">switch<\/span><span style=\"color: #000000\"> (<\/span><span style=\"color: #8b0000\">$PsCmdlet<\/span><span style=\"color: #000000\">.ParameterSetName)\n    {\n        <\/span><span style=\"color: #ff0000\">'Name Set'<\/span><span style=\"color: #000000\"> {\n            <\/span><span style=\"color: #008000\">#TODO: Place script here<\/span><span style=\"color: #000000\">\n            <\/span><span style=\"color: #0000ff\">break<\/span><span style=\"color: #000000\">\n        }\n        <\/span><span style=\"color: #ff0000\">'Data Set'<\/span><span style=\"color: #000000\"> {\n            <\/span><span style=\"color: #008000\">#TODO: Place script here<\/span><span style=\"color: #000000\">\n            <\/span><span style=\"color: #0000ff\">break<\/span><span style=\"color: #000000\">\n        }\n    }<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p>We hope that these new additions and changes will increase your work-flow and make the creation of advanced functions with multiple parameter sets easier then ever.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous article we covered the new Function Builder. In the latest service release of PowerShell Studio 2014 (v4.1.64), we improved parameter set support in the Function Builder. As you can see, we altered the ordering of the fields to improve the over-all work flow of the tool. Notice the question marks? If you [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[703,632,25],"tags":[909,28,874],"class_list":["post-7622","post","type-post","status-publish","format-standard","hentry","category-powershell-studio","category-whats-new-software-news","category-windows-powershell","tag-function-builder","tag-powershell","tag-powershell-studio-2014"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=7622"}],"version-history":[{"count":5,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7622\/revisions"}],"predecessor-version":[{"id":7670,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7622\/revisions\/7670"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=7622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=7622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=7622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}