en-US/Sashimi.dll-Help.xml
|
<?xml version="1.0" encoding="utf-8"?> <helpItems xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" schema="maml" xmlns="http://msh"> <command:command> <command:details> <command:name>ConvertFrom-RawString</command:name> <maml:description> <maml:para>Converts one or more PowerShell strings into byte arrays using the specified encoding, optionally inserting a delimiter between pipeline inputs.</maml:para> </maml:description> <command:verb>ConvertFrom</command:verb> <command:noun>RawString</command:noun> </command:details> <maml:description> <maml:para> `ConvertFrom-RawString` converts a PowerShell `string` into a `byte[]` using the specified encoding. This cmdlet is the counterpart of `ConvertTo-RawString` and is typically used when preparing text for binary‑level pipelines, such as feeding encoded data into `Invoke-RawCommand`.</maml:para> <maml:para> PowerShell normally converts strings to bytes using UTF‑16, but many native tools expect UTF‑8, Shift_JIS, or other encodings. This cmdlet provides explicit control over the encoding used.</maml:para> <maml:para> When multiple strings are provided through the pipeline, `ConvertFrom-RawString` concatenates them by inserting the specified delimiter (if any) before encoding. This allows constructing structured byte sequences such as newline‑separated text or custom‑delimited records.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertFrom-RawString</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>InputString</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="d"> <maml:name>Delimiter</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="d"> <maml:name>Delimiter</maml:name> <maml:description> <maml:para> Specifies a delimiter string to insert before each input string after the first one. When multiple strings are provided through the pipeline, the delimiter is encoded using the selected encoding and written before each subsequent string. This is useful when constructing multi‑line or structured byte sequences, such as inserting newline characters or custom separators between records.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description> <maml:para> Specifies the text encoding used to convert the input string into bytes. Any encoding name accepted by `[System.Text.Encoding]::GetEncoding()` is valid. If omitted, UTF‑8 is used.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="0" aliases="none"> <maml:name>InputString</maml:name> <maml:description> <maml:para> Specifies the string to convert. This parameter accepts pipeline input.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>One or more strings can be piped to this cmdlet. Each string is encoded and emitted as a byte[], with the delimiter inserted before subsequent strings when specified.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> <maml:description> <maml:para>The cmdlet outputs one or more byte[] objects representing the encoded input strings, with delimiters inserted when applicable.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>This cmdlet is intended for precise control of text‑to‑binary conversion, especially when interacting with native commands that require specific encodings.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1 ---------</maml:title> <maml:introduction> <maml:para>Convert a string to Shift_JIS bytes. </maml:para> </maml:introduction> <dev:code>```powershell "こんにちは" | ConvertFrom-RawString -Encoding Shift_JIS ```</dev:code> <dev:remarks> <maml:para>This example produces a `byte[]` representing the Shift_JIS encoding of the input string.</maml:para> <maml:para /> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2 ---------</maml:title> <maml:introduction> <maml:para>Insert a newline delimiter between multiple input strings. </maml:para> </maml:introduction> <dev:code>```powershell "line1","line2","line3" | ConvertFrom-RawString -Delimiter "`n" ```</dev:code> <dev:remarks> <maml:para>This produces a single `byte[]` containing the three lines separated by LF.</maml:para> <maml:para /> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-RawString</maml:linkText> <maml:uri>ConvertTo-RawString.md</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-RawCommand</maml:linkText> <maml:uri>Invoke-RawCommand.md</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Show-HexDump</maml:linkText> <maml:uri>Show-HexDump.md</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>ConvertTo-RawString</command:name> <maml:description> <maml:para>Converts raw byte input into PowerShell strings using the specified encoding, optionally returning the entire decoded text as a single string.</maml:para> </maml:description> <command:verb>ConvertTo</command:verb> <command:noun>RawString</command:noun> </command:details> <maml:description> <maml:para> `ConvertTo-RawString` converts raw `byte[]` input into PowerShell strings using the specified encoding. Unlike simple `[System.Text.Encoding]::GetString()`, this cmdlet is designed for streaming scenarios: it accepts chunked byte arrays and reconstructs text correctly even when multi‑byte characters span chunk boundaries.</maml:para> <maml:para> The cmdlet emits output **one line at a time**, matching PowerShell's line‑oriented pipeline model. This makes it suitable for decoding output from `Invoke-RawCommand`, which emits raw byte chunks from native processes.</maml:para> <maml:para> By default, `ConvertTo-RawString` emits one string per line, matching PowerShell’s line‑oriented pipeline model. When the `-Raw` switch is used, the cmdlet returns the entire decoded text as a single string, preserving all newline characters.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertTo-RawString</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>InputBytes</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">byte[]</command:parameterValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Raw</maml:name> <maml:description /> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description> <maml:para> Specifies the text encoding used to decode the input bytes. Any encoding name accepted by `[System.Text.Encoding]::GetEncoding()` is valid. If omitted, UTF‑8 is used.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="0" aliases="none"> <maml:name>InputBytes</maml:name> <maml:description> <maml:para> Specifies the byte array to decode. This parameter accepts pipeline input and supports chunked streaming.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Byte[]</command:parameterValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="r"> <maml:name>Raw</maml:name> <maml:description> <maml:para> Outputs the entire decoded text as a single string instead of splitting it into lines. When this switch is specified, the cmdlet disables line‑oriented processing and returns the full decoded content in one object, preserving all newline characters exactly as they appear in the input stream.</maml:para> </maml:description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Byte</maml:name> </dev:type> <maml:description> <maml:para>A single byte can be piped to this cmdlet and will be buffered as part of the decoding stream.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> <maml:description> <maml:para>A byte array can be piped to this cmdlet. Each chunk is decoded as part of the continuous stream.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>By default, one string per line is emitted. When `-Raw` is specified, a single string containing the entire decoded content is emitted.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>This cmdlet is designed for robust decoding of streamed binary data, including multi‑byte encodings where characters may span chunk boundaries.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1 ---------</maml:title> <maml:introduction> <maml:para>Decode Shift_JIS bytes into a PowerShell string. </maml:para> </maml:introduction> <dev:code>```powershell $bytes = raw some-command $bytes | ConvertTo-RawString -Encoding Shift_JIS ```</dev:code> <dev:remarks> <maml:para>This example decodes the raw byte output of a native command using Shift_JIS.</maml:para> <maml:para /> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2 ---------</maml:title> <maml:introduction> <maml:para>Return the entire decoded text as a single string. </maml:para> </maml:introduction> <dev:code>```powershell $bytes | ConvertTo-RawString -Raw ```</dev:code> <dev:remarks> <maml:para>This example preserves all newline characters and returns the full decoded content in one object.</maml:para> <maml:para /> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-RawString</maml:linkText> <maml:uri>ConvertFrom-RawString.md</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-RawCommand</maml:linkText> <maml:uri>Invoke-RawCommand.md</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Invoke-RawCommand</command:name> <maml:description> <maml:para>Executes a native command and returns its output as raw bytes or decoded text.</maml:para> </maml:description> <command:verb>Invoke</command:verb> <command:noun>RawCommand</command:noun> </command:details> <maml:description> <maml:para> `Invoke-RawCommand` executes an external process and exposes its output streams as raw `byte[]` data. Unlike standard PowerShell external command invocation, no text encoding, newline normalization, or string conversion is applied. The command’s stdout and stderr streams are emitted exactly as produced by the process.</maml:para> <maml:para> This cmdlet is the foundation of the Sashimi module and enables precise binary‑level interaction with native tools, including those that output non‑UTF8 data, arbitrary binary payloads, or mixed encodings.</maml:para> <maml:para> When a ScriptBlock is provided, the block is executed using PowerShell’s normal execution semantics. External commands inside the ScriptBlock are invoked in raw mode, while PowerShell constructs such as variables, quoting, pipelines, and control flow behave naturally.</maml:para> <maml:para> `Invoke-RawCommand` normally emits raw `byte[]` data with no text encoding or string conversion. When the `-AsString` switch is used, the cmdlet decodes stdout into a PowerShell string for convenience.</maml:para> <maml:para> When `-AsString` is not used, stdout is emitted as raw `byte[]` chunks. Stderr is also captured as raw bytes, but when not selecting raw output modes, stderr is decoded using the encoding specified by `-Encoding` and emitted as `ErrorRecord` messages. This allows stderr to appear as readable text in the PowerShell pipeline while preserving byte‑level fidelity for stdout.</maml:para> <maml:para> The `-Encoding` parameter controls how stderr is decoded (default: UTF‑8). **It also controls how string input from the pipeline is encoded when written to the process’s stdin.** This ensures consistent behavior when interacting with tools that expect specific encodings such as Shift_JIS or EUC-JP.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Invoke-RawCommand</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Command</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="none"> <maml:name>Arguments</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Input</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="o"> <maml:name>Output</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">OutputFrom</command:parameterValue> <dev:type> <maml:name>Sashimi.OutputFrom</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>AsString</maml:name> <maml:description /> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>ThrowOnError</maml:name> <maml:description /> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Invoke-RawCommand</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Script</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Input</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="o"> <maml:name>Output</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">OutputFrom</command:parameterValue> <dev:type> <maml:name>Sashimi.OutputFrom</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>AsString</maml:name> <maml:description /> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>ThrowOnError</maml:name> <maml:description /> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="none"> <maml:name>Arguments</maml:name> <maml:description> <maml:para> Specifies the argument list passed to the native command.</maml:para> <maml:para> Arguments are forwarded without quoting or encoding changes. This parameter accepts remaining arguments, allowing natural PowerShell invocation.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="s"> <maml:name>AsString</maml:name> <maml:description> <maml:para> Returns the command output as decoded text instead of raw bytes.</maml:para> <maml:para> When this switch is specified, the cmdlet internally decodes the captured `byte[]` stream using the encoding specified by the external process (or UTF‑8 if no encoding can be detected). This parameter is intended for convenience when working with commands that reliably produce textual output and do not require byte‑level fidelity.</maml:para> <maml:para> `-AsString` cannot be used together with `ConvertTo-RawString`, since decoding is performed inside the cmdlet.</maml:para> <maml:para>> [!TIP] > *ScriptBlock mode behavior*: > > When using a ScriptBlock (`{ ... }`), `-AsString` is applied **only to the last external command in each external‑command chain**. > > For example: > > ```powershell > Invoke-RawCommand -AsString { > cat path/to/file | > grep 'pattern' | > Select-Object -First 1 | > cut -d' ' -f1 > } > ``` > > The pipeline contains two external‑command chains: > > - `cat` → `grep` > - `cut` > > Therefore, `-AsString` is applied only to: > > - `grep` (last command of the first chain) > - `cut` (last command of the second chain)</maml:para> </maml:description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Command</maml:name> <maml:description> <maml:para> Specifies the native executable to run.</maml:para> <maml:para> This parameter is required when using the Normal parameter set.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description> <maml:para> Specifies the text encoding used for:</maml:para> <maml:para>- decoding stderr when the cmdlet emits string‑based error output - **encoding string input from the pipeline before writing it to stdin** </maml:para> <maml:para> When a string is piped into `Invoke-RawCommand`, it is converted to bytes using this encoding. This allows tools that expect non‑UTF8 input (e.g., Shift_JIS) to receive correctly encoded data.</maml:para> <maml:para> Common values include `UTF-8`, `Shift_JIS`, `EUC-JP`, and other encodings supported by .NET.</maml:para> <maml:para>> [!TIP] > *ScriptBlock mode behavior*: > > Unlike `-AsString`, the specified encoding is applied **uniformly to every external command** inside the ScriptBlock.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="Named" aliases="none"> <maml:name>Input</maml:name> <maml:description> <maml:para> Provides input to the process’s standard input stream.</maml:para> <maml:para> This parameter accepts:</maml:para> <maml:para>- **byte** — written directly to stdin - **byte[]** — forwarded as-is - **string** — encoded using the encoding specified by `-Encoding` </maml:para> <maml:para> When supplied via the pipeline, each chunk is written directly without buffering.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="o"> <maml:name>Output</maml:name> <maml:description> <maml:para> Specifies which output streams to emit.</maml:para> <maml:para> Valid values are defined by the `Sashimi.OutputFrom` enum (e.g., `Stdout`, `Stderr`, `Both`). The selected streams are emitted as raw `byte[]` chunks.</maml:para> <maml:para>> [!TIP] > *ScriptBlock mode behavior*: > > Unlike `-AsString`, the specified encoding is applied **uniformly to every external command** inside the ScriptBlock.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sashimi.OutputFrom</command:parameterValue> <dev:type> <maml:name>Sashimi.OutputFrom</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Script</maml:name> <maml:description> <maml:para> Specifies a ScriptBlock whose first statement is executed as a native command.</maml:para> <maml:para> This enables natural syntax such as:</maml:para> <maml:para>```powershell raw { git status } ```</maml:para> <maml:para> Only the first statement is used; the ScriptBlock is not executed as PowerShell code.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="t, ex"> <maml:name>ThrowOnError</maml:name> <maml:description> <maml:para> Throw an exception (`ExternalCommandNonZeroExit`) when the external command completed but returned non-zero exit code.</maml:para> </maml:description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Byte</maml:name> </dev:type> <maml:description> <maml:para>A single byte value can be piped to `-Input`, which is written directly to the process’s stdin.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> <maml:description> <maml:para>A byte array can be piped to `-Input`. Each array is forwarded as-is to the process’s stdin stream.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>A string can be piped to `Invoke-RawCommand`. The string is encoded using the encoding specified by `-Encoding` (default: UTF‑8) and written to the process’s stdin as raw bytes.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> <maml:description> <maml:para>The cmdlet outputs raw bytes from the selected output streams (`StdOut`, `StdErr`, or both). Each emitted object is a `byte[]` chunk representing data read from the process.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>Returned when `-AsString` is specified. The cmdlet decodes the raw output stream into a PowerShell string using the detected or default encoding.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>This cmdlet bypasses all PowerShell text processing and is intended for scenarios requiring exact byte‑level fidelity, such as binary protocols, non‑UTF8 encodings, or tools that emit mixed binary/text output.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1 ---------</maml:title> <maml:introduction> <maml:para>Run a command and decode its UTF-16 output manually. </maml:para> </maml:introduction> <dev:code>```powershell $bytes = raw wsl.exe --list $bytes | ConvertTo-RawString -Encoding UTF-16 ```</dev:code> <dev:remarks> <maml:para>This example captures the raw byte output from `wsl.exe` and converts it to a string using an explicit encoding.</maml:para> <maml:para /> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2 ---------</maml:title> <maml:introduction> <maml:para>Convert Shift_JIS bytes using `iconv` and return the result as a decoded string. </maml:para> </maml:introduction> <dev:code>```powershell $bytes = ConvertFrom-RawString テスト -Encoding shift_jis $string = $bytes | Invoke-RawCommand iconv '-f' shift_jis -AsString # same as: # `$bytes | Invoke-RawCommand iconv '-f' shift_jis | ConvertTo-RawString` ```</dev:code> <dev:remarks> <maml:para>This example returns the command output as a decoded string without requiring `ConvertTo-RawString`.</maml:para> <maml:para /> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-RawString</maml:linkText> <maml:uri>ConvertFrom-RawString.md</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-RawString</maml:linkText> <maml:uri>ConvertTo-RawString.md</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Show-HexDump</maml:linkText> <maml:uri>Show-HexDump.md</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Out-RawFile</command:name> <maml:description> <maml:para>Writes raw byte input to a file without any text encoding or transformation.</maml:para> </maml:description> <command:verb>Out</command:verb> <command:noun>RawFile</command:noun> </command:details> <maml:description> <maml:para> `Out-RawFile` writes raw `byte[]` data directly to a file. No text encoding, newline normalization, or PowerShell string conversion is applied. This cmdlet is the counterpart to `Get-Content -AsByteStream` and is designed for binary‑safe pipelines, especially when used with `Invoke-RawCommand`, `ConvertFrom-RawString`, and `ConvertTo-RawString`.</maml:para> <maml:para> When `-Append` is specified, data is added to the end of the file. When `-PassThru` is used, the written bytes are emitted back to the pipeline, enabling tee‑like scenarios.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Out-RawFile</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>InputBytes</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">byte[]</command:parameterValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:description /> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Out-RawFile</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>InputBytes</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">byte[]</command:parameterValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description /> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:description /> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="a"> <maml:name>Append</maml:name> <maml:description> <maml:para> Appends the incoming bytes to the end of the file instead of overwriting it. If the file does not exist, it is created.</maml:para> </maml:description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="Named" aliases="none"> <maml:name>InputBytes</maml:name> <maml:description> <maml:para> Specifies the raw byte array to write to the file. This parameter accepts pipeline input and supports chunked streaming.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Byte[]</command:parameterValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="p"> <maml:name>PassThru</maml:name> <maml:description> <maml:para> Outputs the written bytes back to the pipeline. This is useful for chaining additional processing or for tee‑style workflows.</maml:para> </maml:description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para> Specifies the file path to write to. Relative paths are resolved using PowerShell’s path resolution rules.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Byte</maml:name> </dev:type> <maml:description> <maml:para>A single byte can be piped to this cmdlet and will be written to the file.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> <maml:description> <maml:para>A byte array can be piped to this cmdlet. Each chunk is written directly to the file.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Void</maml:name> </dev:type> <maml:description> <maml:para>By default, this cmdlet produces no output.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> <maml:description> <maml:para>When `-PassThru` is specified, the written bytes are emitted back to the pipeline.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>This cmdlet provides the missing counterpart to `Get-Content -AsByteStream`, enabling fully binary‑safe pipelines in PowerShell. It is optimized for streaming scenarios and large binary data.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1 ---------</maml:title> <maml:introduction> <maml:para>Write raw bytes to a file. </maml:para> </maml:introduction> <dev:code>```powershell raw some-command | Out-RawFile output.bin ```</dev:code> <dev:remarks> <maml:para>This example captures the raw byte output of a native command and writes it directly to `output.bin`.</maml:para> <maml:para /> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-RawCommand</maml:linkText> <maml:uri>Invoke-RawCommand.md</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-RawString</maml:linkText> <maml:uri>ConvertFrom-RawString.md</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-RawString</maml:linkText> <maml:uri>ConvertTo-RawString.md</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Show-HexDump</command:name> <maml:description> <maml:para>Dump the data hexadecimal.</maml:para> </maml:description> <command:verb>Show</command:verb> <command:noun>HexDump</command:noun> </command:details> <maml:description> <maml:para> Like the `hexdump` Unix-like command, it reads a given byte sequence, stream, or file and dumps it hexadecimal. It also outputs the result of the text conversion of the byte sequence.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Show-HexDump</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="d"> <maml:name>Data</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">byte[]</command:parameterValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Config</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">Config</command:parameterValue> <dev:type> <maml:name>Sashimi.HexDump.Config</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Offset</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">long</command:parameterValue> <dev:type> <maml:name>System.Int64</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Length</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="c"> <maml:name>Color</maml:name> <maml:description /> <command:parameterValueGroup> <command:parameterValue required="false" variableLength="false">None</command:parameterValue> <command:parameterValue required="false" variableLength="false">ByByte</command:parameterValue> <command:parameterValue required="false" variableLength="false">ByUnicodeCategory</command:parameterValue> <command:parameterValue required="false" variableLength="false">ByCharType</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">ColorType</command:parameterValue> <dev:type> <maml:name>Sashimi.HexDump.ColorType</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="v"> <maml:name>View</maml:name> <maml:description /> <command:parameterValueGroup> <command:parameterValue required="false" variableLength="false">Split</command:parameterValue> <command:parameterValue required="false" variableLength="false">Unified</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">ViewType</command:parameterValue> <dev:type> <maml:name>Sashimi.HexDump.ViewType</maml:name> </dev:type> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Show-HexDump</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Config</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">Config</command:parameterValue> <dev:type> <maml:name>Sashimi.HexDump.Config</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Offset</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">long</command:parameterValue> <dev:type> <maml:name>System.Int64</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Length</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">int</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="c"> <maml:name>Color</maml:name> <maml:description /> <command:parameterValueGroup> <command:parameterValue required="false" variableLength="false">None</command:parameterValue> <command:parameterValue required="false" variableLength="false">ByByte</command:parameterValue> <command:parameterValue required="false" variableLength="false">ByUnicodeCategory</command:parameterValue> <command:parameterValue required="false" variableLength="false">ByCharType</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">ColorType</command:parameterValue> <dev:type> <maml:name>Sashimi.HexDump.ColorType</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="v"> <maml:name>View</maml:name> <maml:description /> <command:parameterValueGroup> <command:parameterValue required="false" variableLength="false">Split</command:parameterValue> <command:parameterValue required="false" variableLength="false">Unified</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">ViewType</command:parameterValue> <dev:type> <maml:name>Sashimi.HexDump.ViewType</maml:name> </dev:type> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="c"> <maml:name>Color</maml:name> <maml:description> <maml:para> Color scheme settings for hexadecimal dump columns and textualized columns</maml:para> <maml:para>- `None`: no color - `ByByte`: color scheme based on byte values - `ByUnicodeCategory`: color scheme based on Unicode categories - `ByCharType`: color scheme based on ASCII control characters, ASCII characters and multi-byte characters values that could not be decoded into characters, etc. </maml:para> <maml:para> It overrides the `Config` setting.</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" variableLength="false">None</command:parameterValue> <command:parameterValue required="false" variableLength="false">ByByte</command:parameterValue> <command:parameterValue required="false" variableLength="false">ByUnicodeCategory</command:parameterValue> <command:parameterValue required="false" variableLength="false">ByCharType</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="true">Sashimi.HexDump.ColorType</command:parameterValue> <dev:type> <maml:name>Sashimi.HexDump.ColorType</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Config</maml:name> <maml:description> <maml:para> A set of settings including encoding, color scheme settings, etc.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sashimi.HexDump.Config</command:parameterValue> <dev:type> <maml:name>Sashimi.HexDump.Config</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="0" aliases="d"> <maml:name>Data</maml:name> <maml:description> <maml:para> Byte array to be dumped</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Byte[]</command:parameterValue> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description> <maml:para> Encoding used to decode byte strings into characters</maml:para> <maml:para> You can also specify the `System.Text.Encoding` type directly, or specify a name or codepage that can be used in `System.Text.Encoding.GetEncoding(name or codepage)`.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Length</maml:name> <maml:description> <maml:para> Length from the dump start position to the end. If not specified, to the end.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Offset</maml:name> <maml:description> <maml:para> Dump start position. If not specified, read from the beginning.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Int64</command:parameterValue> <dev:type> <maml:name>System.Int64</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para> Target file path to dump.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="v"> <maml:name>View</maml:name> <maml:description> <maml:para> Output Format.</maml:para> <maml:para> The following can be specified:</maml:para> <maml:para>- `Split` (default): displays hex values and character values in separate columns. - `Unified`: displays the hex value on the first line and the character value on the second line in a single column.</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" variableLength="false">Split</command:parameterValue> <command:parameterValue required="false" variableLength="false">Unified</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="true">Sashimi.HexDump.ViewType</command:parameterValue> <dev:type> <maml:name>Sashimi.HexDump.ViewType</maml:name> </dev:type> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> <maml:description> <maml:para>Byte sequence to dump. (See: `-Data` parameter) Note that giving a sequence of bytes from the pipeline requires a little ingenuity. You will need to add a `NoEnumerate` parameter to `Write-Output` (Alias: `echo`). ```powershell $bytes = @(...) Write-Output -NoEnumerate $bytes | Show-HexDump ... ```</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Sashimi.HexDump.SplitView</maml:name> </dev:type> <maml:description> <maml:para>A view that displays hex values and character values in separate columns. This is default view.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>Sashimi.HexDump.UnifiedView</maml:name> </dev:type> <maml:description> <maml:para>A view that displays the hex value on the first line and the character value on the second line in a single column. See `-View` parameter.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para /> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1. List ASCII codes ---------</maml:title> <maml:introduction /> <dev:code>```powershell Show-HexDump -Data @(0x00..0x7F) ```</dev:code> <dev:remarks> <maml:para>Output:</maml:para> <maml:para>``` Offset Hex 2 3 4 5 6 7 8 9 A B C D E F C 1 2 3 4 5 6 7 8 9 A B C D E F ------ ---------------------------------------------- ------------------------------- 0x00000000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ␀ ␁ ␂ ␃ ␄ ␅ ␆ ␇ ␈ ␉ ␊ ␋ ␌ ␍ ␎ ␏ 0x00000010 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F ␐ ␑ ␒ ␓ ␔ ␕ ␖ ␗ ␘ ␙ ␚ ␛ ␜ ␝ ␞ ␟ 0x00000020 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F ! " # $ % & ' ( ) * + , - . / 0x00000030 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 0x00000040 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F @ A B C D E F G H I J K L M N O 0x00000050 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F P Q R S T U V W X Y Z [ \ ] ^ _ 0x00000060 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F ` a b c d e f g h i j k l m n o 0x00000070 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F p q r s t u v w x y z { | } ~ ␡ ```</maml:para> <maml:para /> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2. Hexadecimal dump and textualized data in one column ---------</maml:title> <maml:introduction /> <dev:code>```powershell Show-HexDump -Data @(0x00..0x7F) -Format Unified ```</dev:code> <dev:remarks> <maml:para>Output:</maml:para> <maml:para>``` Offset Hex and Chars ------ ------------- 0x00000000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ␀ ␁ ␂ ␃ ␄ ␅ ␆ ␇ ␈ ␉ ␊ ␋ ␌ ␍ ␎ ␏ 0x00000010 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F ␐ ␑ ␒ ␓ ␔ ␕ ␖ ␗ ␘ ␙ ␚ ␛ ␜ ␝ ␞ ␟ 0x00000020 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F ! " # $ % & ' ( ) * + , - . / 0x00000030 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 0x00000040 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F @ A B C D E F G H I J K L M N O 0x00000050 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F P Q R S T U V W X Y Z [ \ ] ^ _ 0x00000060 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F ` a b c d e f g h i j k l m n o 0x00000070 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F p q r s t u v w x y z { | } ~ ␡ ```</maml:para> <maml:para /> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-RawCommand</maml:linkText> <maml:uri>Invoke-RawCommand.md</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-RawString</maml:linkText> <maml:uri>ConvertFrom-RawString.md</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Test-RawCommand</command:name> <maml:description> <maml:para>Executes an external command and returns true/false based the process's exit code.</maml:para> </maml:description> <command:verb>Test</command:verb> <command:noun>RawCommand</command:noun> </command:details> <maml:description> <maml:para> `Test-RawCommand` executes an external command and evaluates its success based on the process’s exit code.</maml:para> <maml:para> The cmdlet returns a Boolean value:</maml:para> <maml:para>- `true` when the process exits with code `0` - `false` when the process exits with any non‑zero exit code </maml:para> <maml:para> Unlike `Invoke-RawCommand`, this cmdlet does not return raw output data. Instead, all stdout and stderr output is emitted as `InformationRecord` objects. Each record is tagged with the originating stream (`Stdout` or `Stderr`), allowing callers to inspect diagnostic output while still receiving a simple Boolean result.</maml:para> <maml:para> This cmdlet is intended for scenarios where only success/failure matters—such as conditional execution, assertions, or automation checks—while still preserving access to the command’s textual output for logging or debugging.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Test-RawCommand</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Command</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="none"> <maml:name>Arguments</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>Input</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="none"> <maml:name>AsString</maml:name> <maml:description /> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description /> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="none"> <maml:name>Arguments</maml:name> <maml:description> <maml:para> Specifies the argument list passed to the external command.</maml:para> <maml:para> Arguments are forwarded without quoting or encoding changes. This parameter accepts remaining arguments, allowing natural PowerShell invocation.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="s"> <maml:name>AsString</maml:name> <maml:description> <maml:para> Returns the command output as decoded text instead of raw bytes.</maml:para> <maml:para> When this switch is specified, the cmdlet internally decodes the captured `byte[]` stream using the encoding specified by the external process (or UTF‑8 if no encoding can be detected). This parameter is intended for convenience when working with commands that reliably produce textual output and do not require byte‑level fidelity.</maml:para> </maml:description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> </dev:type> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Command</maml:name> <maml:description> <maml:para> Specifies the external executable to run.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="e"> <maml:name>Encoding</maml:name> <maml:description> <maml:para> Specifies the text encoding used for:</maml:para> <maml:para>- decoding stderr when the cmdlet emits string‑based error output - **encoding string input from the pipeline before writing it to stdin** </maml:para> <maml:para> When a string is piped into `Test-RawCommand`, it is converted to bytes using this encoding. This allows tools that expect non‑UTF8 input (e.g., Shift_JIS) to receive correctly encoded data.</maml:para> <maml:para> Common values include `UTF-8`, `Shift_JIS`, `EUC-JP`, and other encodings supported by .NET.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="Named" aliases="none"> <maml:name>Input</maml:name> <maml:description> <maml:para> Provides input to the process’s standard input stream.</maml:para> <maml:para> This parameter accepts:</maml:para> <maml:para>- **byte** — written directly to stdin - **byte[]** — forwarded as-is - **string** — encoded using the encoding specified by `-Encoding` </maml:para> <maml:para> When supplied via the pipeline, each chunk is written directly without buffering.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> </dev:type> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Byte</maml:name> </dev:type> <maml:description> <maml:para>A single byte value can be piped to `-Input`, which is written directly to the process’s stdin.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.Byte[]</maml:name> </dev:type> <maml:description> <maml:para>A byte array can be piped to `-Input`. Each array is forwarded as-is to the process’s stdin stream.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>A string can be piped to `Test-RawCommand`. The string is encoded using the encoding specified by `-Encoding` (default: UTF‑8) and written to the process’s stdin as raw bytes.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Boolean</maml:name> </dev:type> <maml:description> <maml:para>`$true` indicates the process's exit code is `0`, Otherwise `$false`.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- ScriptBlock invocation is not supported. `Test-RawCommand` always executes a native executable and evaluates its exit code. - When `-AsString` is specified, stdout and stderr are decoded using the encoding selected by `-Encoding`. The decoded text is emitted as `InformationRecord` objects. - Input provided via the pipeline must be either `string` or `byte[]`. Other types will result in a terminating error. - This cmdlet is built on top of the same execution engine used by `Invoke-RawCommand`, but returns only a Boolean result instead of raw output.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1. use in `if` statement ---------</maml:title> <maml:introduction /> <dev:code>```powershell if (Test-RawCommand grep pattern path/to/file) { # success } else { throw "NotFound"; } ```</dev:code> <dev:remarks> <maml:para /> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2. Getting stdout/Stderr ---------</maml:title> <maml:introduction /> <dev:code>```powershell if (Test-RawCommand -AsString path/to/executable -InformationVariable info) { # Success $stdout = $info.Where({$_.Tags -in "Stdout"}).MessageData.Value Write-Output $stdout } else { $stderr = $info.Where({$_.Tags -in "Stderr"}).MessageData.Value throw "Failed" } ```</dev:code> <dev:remarks> <maml:para /> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-RawCommand</maml:linkText> <maml:uri>Invoke-RawCommand.md</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> </helpItems> |