Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Format-Hex

Format-Hex

pscx.dll

Synopsis

PSCX Cmdlet: Displays the contents of files or byte streams in hex format and optionally ASCII.

Syntax

Format-Hex [-InputObject] [-Columns] [-Count] [-HideAddress] [-HideAscii] [-HideHeader] [-Offset] [-StringEncoding] [-Width] [<CommonParameters>]

Format-Hex [-Path] [-Columns] [-Count] [-HideAddress] [-HideAscii] [-HideHeader] [-Offset] [-Width] [<CommonParameters>]

Format-Hex [-LiteralPath] [-Columns] [-Count] [-HideAddress] [-HideAscii] [-HideHeader] [-Offset] [-Width] [<CommonParameters>]

Detailed Description

The Format-Hex command displays the contents of the specified files in hex format. This cmdlet will also accept pipeline input in the form of a byte stream. The output can be controlled via various parameters to indicate the number of columns that should be displayed or alternatively you can specify the width of the output. The header, address and ASCII portions of the display can also be turned off individually. The offset and count can also be specified via parameters to control where in the input to start displaying and how much to display.

Parameters

-LiteralPath <String[]>

Specifies a path to the item. The value of -LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Path <String[]>

Specifies the path to the file to process. Wildcard syntax is allowed.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

true

-InputObject <PSObject>

Accepts an object as input to the cmdlet. Enter a variable that contains the objects or type a command or expression that gets the objects.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-Columns <Int32>

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Count <Int32>

Specifies the number of bytes to display.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-HideAddress <SwitchParameter>

Hides the address information.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-HideAscii <SwitchParameter>

Hides the ASCII representation of the bytes.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-HideHeader <SwitchParameter>

Hides the header lines.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Offset <Int64>

Specifies the number of bytes to offset into file.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-StringEncoding <StringEncodingParameter>

The encoding to use for string InputObjects. Valid values are: ASCII, UTF7, UTF8, UTF32, Unicode, BigEndianUnicode and Default.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Width <Int32>

Specifies desired width of output text.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

byte
byte[]
string

Return Type

Formatted text

Notes

Strings can be viewed in hex but because the cmdlet interprets pipeline input of type string to specify a file path you need to use the -InputObject parameter. See example number three below.

Examples

-------------------------- EXAMPLE 1 --------------------------

This displays the first 256 bytes of the PowerShell executable.

C:\PS>Format-Hex $pshome\PowerShell.exe -Count 256

-------------------------- EXAMPLE 2 --------------------------

This examples accepts a byte array as input and displays those byte values in hex and ASCII.

C:\PS>[byte[]](1..255) | Format-Hex

-------------------------- EXAMPLE 3 --------------------------

In this scenario the string is always converted to bytes assuming the string encoding is Unicode which is true of PowerShell strings.

C:\PS>"hello world" | Format-Hex -InputObject {$_}

-------------------------- EXAMPLE 4 --------------------------

If you want to view the bytes using an alternate encoding then use the -StringEncoding parameter to specify the preferred encoding.

C:\PS>"hello world" | Format-Hex -InputObject {$_} -StringEncoding ASCII