Convert Linux shell commands into PowerShell cmdlets

New Harmonies

Command Output Processing

PowerShell implements a type of object orientation in terms of data processing. Many cmdlets return information in the form of structs. Scripts can specifically address the values structs contain to further process only the required parts of the information downstream.

It follows that PowerShell Crescendo also provides logic in this area that converts the results returned by command-line tools into the PowerShell idiom. The simplest handler is an inline element, a single line of code that converts the supplied results directly into a PowerShell object (Listing 4).

Listing 4

Converting to a PowerShell Object

01 {
02     "$schema": "../src/Microsoft.PowerShell.Crescendo.Schema.json",
03    "Commands": [
04      {
05       "Verb": "New",
06        "Noun": "Command1",
07        "OriginalName": "<path><command>",
08        "OutputHandlers": [
09          {
10             "ParameterSetName": "viaInline",
11             "HandlerType": "Inline",
12             "Handler": "$args[0] | ConvertFrom-Json"
13          }
14        ]
15     },

Alternatively, you have the option to do the processing with the use of a dedicated script. An OutputHandler of the type Script is responsible; it can call more or less any other script:

."Verb": "New",
."Noun": "Command2",
."OutputHandlers": [
... "ParameterSetName": "viaScript",
... "HandlerType": "Script",
... "Handler": "Convert-GetDate.ps1"

Last but not least, Crescendo lets you use functions already in the PowerShell environment to process data by setting the HandlerType to Function:

."Verb": "New",
."Noun": "Command3",
."OutputHandlers": [
... "ParameterSetName": "viaFunction",
... "HandlerType": "Function",
... "Handler": "Convert-GetDate"

Note that using an in-house PowerShell function like Function establishes a relationship between the Crescendo wrapper and that function. When deploying the wrapper, you must be careful to establish this relationship (this is usually a manual process). A script created as "HandlerType": "Script" transposes Crescendo into the wrapper, which is why you do not need to supply it separately on distribution.


PowerShell Crescendo offers administrators a powerful tool that extends the reach of PowerShell far beyond the Windows domain. Microsoft is planning to launch a GitHub-style directory at some point, in which administrators and developers can exchange Crescendo wrappers. In combination with the availability of PowerShell for various non-Microsoft operating systems, the script environment is developing into a true jack-of-all-trades.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs

Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>


		<div class=