Skip to content
ConsoleMonster
Cmdlet

Format-ConsoleCommand

Module
ConsoleMonster
Inputs
None
Outputs
System.String

Builds a copyable command line from named values without executing it.

Syntax

Format-ConsoleCommand
-Arguments <IDictionary>
-Command <String>
[-Style <PowerShell|Posix|Windows>]
[<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Formats strings, numbers, switches and lists through the same quoting rules as forms. Use an ordered dictionary to retain argument order. Null, empty strings and false switches are omitted. The result is a plain string, suitable for a review's equivalent command.

Examples

Example 1

Format-ConsoleCommand -Command Invoke-FleetCheck -Arguments ([ordered]@{ ComputerName = @('WEB01', 'SQL01'); ThrottleLimit = 3; WhatIf = $true })

Build an equivalent command from selected servers

Parameters

-Arguments IDictionary required
Parameter names and values. Use an ordered dictionary when order matters.
-Command String required
The command text, which is never executed.
-Style CommandStyle optional
PowerShell, Posix or Windows argument quoting (default PowerShell).
Possible values: PowerShell, Posix, Windows

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.