{"id":19086,"date":"2021-07-27T08:17:21","date_gmt":"2021-07-27T16:17:21","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/powershell\/?p=19086"},"modified":"2021-07-27T08:17:21","modified_gmt":"2021-07-27T16:17:21","slug":"announcing-powershell-crescendo-preview-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/announcing-powershell-crescendo-preview-3\/","title":{"rendered":"Announcing PowerShell Crescendo Preview.3"},"content":{"rendered":"<p>We are pleased to announce the third preview of <strong>PowerShell Crescendo<\/strong>, a framework to rapidly\ndevelop PowerShell cmdlets for native commands, regardless of platform.<\/p>\n<p><div class=\"alert alert-warning\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Warning\"><\/i><strong>Warning<\/strong><\/p> Preview.3 includes a change to the schema to support\nmultiple command configurations. This is a breaking change from previous previews. To enjoy the new\nmulti-command JSON format, please upgrade to the latest preview.<\/div><\/p>\n<p>The updated preview release is now available for download on the PowerShell Gallery:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.powershellgallery.com\/packages\/Microsoft.PowerShell.Crescendo\/0.6.1\">Microsoft.PowerShell.Crescendo Preview 3<\/a><\/li>\n<\/ul>\n<p>To install <strong>Microsoft.PowerShell.Crescendo<\/strong>:<\/p>\n<pre><code class=\"language-powershell\">Install-Module Microsoft.PowerShell.Crescendo -AllowPrerelease<\/code><\/pre>\n<p>For more information on <strong>Microsoft.PowerShell.Crescendo<\/strong>, check out these previous blog posts:<\/p>\n<ul>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/announcing-powershell-crescendo-preview-2\/\">Announcing PowerShell Crescendo Preview.2<\/a><\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/announcing-powershell-crescendo-preview-1\/\">Announcing PowerShell Crescendo Preview.1<\/a><\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/native-commands-in-powershell-a-new-approach\/\">Native Commands in PowerShell Part 1<\/a><\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/native-commands-in-powershell-a-new-approach-part-2\/\">Native Commands in PowerShell Part 2<\/a><\/li>\n<\/ul>\n<h2>Crescendo Preview 3 Updates<\/h2>\n<p><strong>Crescendo 0.6.1-Preview.3<\/strong> adds support to handle multiple command definitions per JSON\nconfiguration and additional output handling options. Read the full list of changes\nbelow:<\/p>\n<ul>\n<li>Added support for multiple commands per JSON configuration.\n<a href=\"https:\/\/github.com\/PowerShell\/Crescendo\/issues\/49\">Issue #49<\/a><\/li>\n<li>Added additional output handler options inline, function, and script.\n<a href=\"https:\/\/github.com\/PowerShell\/Crescendo\/issues\/33\">Issue #33<\/a><\/li>\n<li>Added additional proxy generation code cleanup<\/li>\n<\/ul>\n<h2>Support multiple command definitions per JSON configuration<\/h2>\n<p>To improve the development and distribution of Crescendo wrapped commands, the schema for Crescendo\nhas been extended to support multiple command definitions in a single JSON file. A new keyword\n<code>Commands<\/code> creates an additional tier to the hierarchy, followed by single or multiple command\ndefinitions. This is a breaking change from previous previews.<\/p>\n<p>In the example below, each command definition is located inside the <code>Commands<\/code> keyword.<\/p>\n<pre><code class=\"language-json\">{\r\n    \"$schema\": \".\/Microsoft.PowerShell.Crescendo.Schema.json\",\r\n    \"Commands\": [\r\n         {\r\n             \"Verb\": \"New\",\r\n             \"Noun\": \"Command1\",\r\n             \"OriginalName\":\"&lt;path&gt;&lt;command&gt;\"\r\n         },\r\n         {\r\n            \"Verb\": \"New\",\r\n            \"Noun\": \"Command2\",\r\n            \"OriginalName\":\"&lt;path&gt;&lt;command&gt;\"\r\n         },\r\n         {\r\n            \"Verb\": \"New\",\r\n            \"Noun\": \"Command3\",\r\n            \"OriginalName\":\"&lt;path&gt;&lt;command&gt;\"\r\n         }\r\n    ]\r\n}<\/code><\/pre>\n<p>Additional per command features such as parameter definitions and administrative elevation may be\nadded to single or multiple command definitions. Check out these blogs for more information about\n<a href=\"https:\/\/devblogs.microsoft.com\/powershell\/announcing-powershell-crescendo-preview-1\/\">parameters<\/a>\nand\n<a href=\"https:\/\/devblogs.microsoft.com\/powershell\/announcing-powershell-crescendo-preview-2\/\">elevation<\/a>.<\/p>\n<h2>Support additional OutputHandlers<\/h2>\n<p>Output handlers take the text output (string) from a native command and convert those strings to\nobjects. Crafting custom output handlers is complex unless the native commands produce structured\noutput such as XML or JSON. To provide authors with development and deployment flexibility,\nCrescendo supports three types of output handlers: <strong>inline<\/strong>, <strong>script<\/strong>, and <strong>function<\/strong>.<\/p>\n<ul>\n<li><strong>Inline<\/strong> &#8211; Authors construct the output handler code inside the cmdlet definition. When\nCrescendo generates the module, the output handler code is written directly into the proxy\nfunction for the new cmdlet.<\/li>\n<li><strong>Script<\/strong> &#8211; Authors may choose to develop the output handler in a separate script to isolate\ntroubleshooting. The <code>Handler<\/code> keyword supports the path and script name to be included. Crescendo\ngenerates the module (.psm1) containing the proxy cmdlet, the manifest (.psd1), and includes the\nspecified script as an additional asset.<\/li>\n<li><strong>Function<\/strong> &#8211; Authors may already have written output handlers that have been imported into\nPowerShell as functions. Crescendo adds the imported function to the generated module outside of\nthe proxy cmdlet.<\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\r\n    \"$schema\": \".\/Microsoft.PowerShell.Crescendo.Schema.json\",\r\n    \"Commands\": [\r\n         {\r\n             \"Verb\": \"New\",\r\n             \"Noun\": \"Command1\",\r\n             \"OriginalName\":\"&lt;path&gt;&lt;command&gt;\",\r\n             \"OutputHandlers\": [\r\n                {\r\n                  \"ParameterSetName\": \"viaInline\",\r\n                  \"HandlerType\": \"Inline\",\r\n                  \"Handler\": \"$args[0] | ConvertFrom-Json\"\r\n                }\r\n             ]\r\n         },\r\n         {\r\n            \"Verb\": \"New\",\r\n            \"Noun\": \"Command2\",\r\n            \"OriginalName\":\"&lt;path&gt;&lt;command&gt;\",\r\n            \"OutputHandlers\": [\r\n                {\r\n                  \"ParameterSetName\": \"viaScript\",\r\n                  \"HandlerType\": \"Script\",\r\n                  \"Handler\": \"Convert-GetDate.ps1\"\r\n                }\r\n            ]\r\n         },\r\n         {\r\n            \"Verb\": \"New\",\r\n            \"Noun\": \"Command3\",\r\n            \"OriginalName\":\"&lt;path&gt;&lt;command&gt;\",\r\n            \"OutputHandlers\": [\r\n                {\r\n                  \"ParameterSetName\": \"viaFunction\",\r\n                  \"HandlerType\": \"Function\",\r\n                  \"Handler\": \"Convert-GetDate\"\r\n                }\r\n            ]\r\n         }\r\n    ]\r\n}<\/code><\/pre>\n<p><div class=\"alert alert-information\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Warning\"><\/i><strong>information<\/strong><\/p> Both <strong>script<\/strong> and <strong>function<\/strong> use <code>Get-Command<\/code>\nto determine the availability of the handler. Be sure that the handler may be found by <code>Get-Command<\/code>\nbefore using <code>Export-CrescendoModule<\/code>.<\/div><\/p>\n<p>For an example of working with an inline output handler, including parameters, see\n<a href=\"https:\/\/devblogs.microsoft.com\/powershell\/announcing-powershell-crescendo-preview-1\/\">Announcing PowerShell Crescendo Preview.1<\/a><\/p>\n<h2>Future plans<\/h2>\n<p>Next\/Future plans for preview.4 will be based on feedback and include a few items under investigation:<\/p>\n<ul>\n<li>Improved tooling for discovery of Crescendo generated modules<\/li>\n<li>Improved cmdlet support including <code>New-CrescendoCommand<\/code> and <code>Export-CrescendoModule<\/code><\/li>\n<\/ul>\n<p>Our goal is to make it easier to convert your native commands to PowerShell cmdlets and receive the\nbenefits that PowerShell provides. We value your ideas and feedback and hope you will give Crescendo\na try, then stop by our GitHub repository and let us know of any issues or features you would like\nadded.<\/p>\n<p>For more information about <strong>PowerShell Crescendo<\/strong> issues and features, see:\n<a href=\"https:\/\/github.com\/PowerShell\/Crescendo\">Crescendo on GitHub<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Improving the development and distribution of Crescendo modules, this preview adds support for multiple command definitions per JSON file, and multiple output handlers to wrap native command output into objects.<\/p>\n","protected":false},"author":7527,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[3173],"class_list":["post-19086","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-powershell-crescendo"],"acf":[],"blog_post_summary":"<p>Improving the development and distribution of Crescendo modules, this preview adds support for multiple command definitions per JSON file, and multiple output handlers to wrap native command output into objects.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/19086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/7527"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=19086"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/19086\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=19086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=19086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=19086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}