Discovering legacy commands

The commands which are implemented for the Orchard.exe utility are regarded by OrchardPs as legacy commands. These commands can also be used from the OrchardPs utility. However, as they return text and not objects, they are not as useful as regular cmdlets.

To get all legacy commands available for the specified tenant, you can get the child items of the Commands node, using the following command:

ls Orchard:\Tenants\Default\Commands

Invoking legacy commands

You can invoke a legacy command using the Invoke-OrchardCommand cmdlet (you can also use the predefined alias ioc). The cmdlet's parameter is the legacy command to invoke and its parameters. For example, to invoke the legacy help commands command, you can use the following command:

Invoke-OrchardCommand help commands
The command is executed on the tenant specified by the current location in the Orchard drive. If the current location is not a tenant directory (or one of its subdirectories), then the Default tenant is used.

The output of the legacy command is returned to the PowerShell environment as a string object. You can use this object inside PowerShell by assigning the result of the Invoke-OrchardCommand cmdlet to a variable. You can use this technique to parse the result of the command and process it in PowerShell. For example the following code changes the output to upper case:

$result = Invoke-OrchardCommand help commands
$result.ToUpper()
By default the Invoke-OrchardCommand cmdlet executes the specified command and returns the output of the command after it is completed. If a legacy command runs for a long time and outputs progress information, the output will not be visible before the command finishes its execution. To avoid this behavior, you can use the -DirectConsole switch, which will print the output directly to the standard output while the command is executing. The drawback of this approach is that you cannot use the output of the command in PowerShell, since the output is not returned as an object from the cmdlet.

For information, see the help file for the Get-OrchardCommand cmdlet:
Get-Help Invoke-OrchardCommand

Last edited Jun 9, 2014 at 11:10 AM by MpDzik, version 5

Comments

No comments yet.