Building Command Parameters with Crescendo
In the previous article, we began exploring the process of using the Crescendo module. This module is designed to make it easier to wrap native command-line tools into a PowerShell command. The Crescendo module is intended to accelerate this process, although if you have sufficient PowerShell scripting experience, you may decide to forego this module and do your own thing.
For my demonstration, I am using the du.exe command from Sysinternals. I have copied it to C:\Windows, so I don’t have to worry about specifying a path. Last time, we started building a Crescendo command. Here’s a recap of the commands.
Import-Module Microsoft.PowerShell.Crescendo
$commands = @()
$cmd = New-CrescendoCommand -Verb Get -Noun FolderUsage -OriginalName du.exe
$cmd.Platform = @('Windows')
$cmd.Aliases = @('psdu')
$cmd.OriginalCommandElements = @('-c', '-nobanner')
$cmd.OriginalText = $(du -? | Out-String)
$cmd.usage = New-UsageInfo -usage "Get folder usage data"
$cmd.Description = 'Get folder usage statistics using the du.exe utility from Sysinternals. It is assumed du.exe exists in your path.'
$example = @{
Command = 'Get-FolderUsage -Path D:\ -NoRecurse'
Description = 'Get root folder usage from D:\'
OriginalCommand = 'du -c -nobanner d:\'
}
$cmd.Examples += New-ExampleInfo @example
$example = @{
Command = 'Get-FolderUsage -Path C:\work -Level 1'
Description = 'Get top-level folder usage for the root C:\work'
OriginalCommand = 'du -c -nobanner -l 1 c:\work'
}
$cmd.Examples += New-ExampleInfo @example
This is what I have defined.
Want to read the full issue?