< Back
Remove-ByteArrayPadding
Post
NAME Remove-ByteArrayPadding
SYNOPSIS
Removes padding from the beginning or end of a byte array.
SYNTAX
Remove-ByteArrayPadding [[-InputObject] <Byte[]>] [-FromEnd] [-Padding <Byte>] [<CommonParameters>]
Remove-ByteArrayPadding [[-ReferenceObject] <PSReference>] [-FromEnd] [-Padding <Byte>] [<CommonParameters>]
DESCRIPTION
This cmdlet removes the padding from the beginning or end of an array and provides a new or modified array
with those bytes removed. The caller can specify the byte that is used as padding and provide the input array
either through the pipeline, parameter, or by reference. When passed by reference, nothing is returned to
the pipeline.
PARAMETERS
-InputObject <Byte[]>
The byte array to remove padding from.
Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-ReferenceObject <PSReference>
The reference to a byte array that will have padding removed from it. The reference will point to a different
location in memory after the cmdlet is complete if any modifications have been done.
Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-FromEnd [<SwitchParameter>]
Specifies that padding is removed from the tail end of the array instead of the beginning.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Padding <Byte>
The byte character that is used as padding to be removed. This defaults to 0x00.
Required? false
Position? named
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.Byte[]
OUTPUTS
System.Byte[] or None
NOTES
AUTHOR: Michael Haken
LAST UPDATE: 1/22/2018
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$Arr = @(0x00, 0x00, 0x00, 0x01)
Remove-ByteArrayPadding -InputObject $Arr
The results of this cmdlet will produce a new array with contents @(0x01).
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>$Arr = @(0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF)
([ref]$Arr) | Remove-ByteArrayPadding -Padding 0xFF -FromEnd
This example demonstrates several things. First the input array can be passed by reference through the pipeline.
After the cmdlet complete, the variable $Arr will contain @(0x00, 0x00, 0x00, 0x01). The cmdlet specified the
padding
character to 0xFF and it removed the padding from the end of the array instead of the beginning.
RELATED LINKS
SYNOPSIS
Removes padding from the beginning or end of a byte array.
SYNTAX
Remove-ByteArrayPadding [[-InputObject] <Byte[]>] [-FromEnd] [-Padding <Byte>] [<CommonParameters>]
Remove-ByteArrayPadding [[-ReferenceObject] <PSReference>] [-FromEnd] [-Padding <Byte>] [<CommonParameters>]
DESCRIPTION
This cmdlet removes the padding from the beginning or end of an array and provides a new or modified array
with those bytes removed. The caller can specify the byte that is used as padding and provide the input array
either through the pipeline, parameter, or by reference. When passed by reference, nothing is returned to
the pipeline.
PARAMETERS
-InputObject <Byte[]>
The byte array to remove padding from.
Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-ReferenceObject <PSReference>
The reference to a byte array that will have padding removed from it. The reference will point to a different
location in memory after the cmdlet is complete if any modifications have been done.
Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-FromEnd [<SwitchParameter>]
Specifies that padding is removed from the tail end of the array instead of the beginning.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Padding <Byte>
The byte character that is used as padding to be removed. This defaults to 0x00.
Required? false
Position? named
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.Byte[]
OUTPUTS
System.Byte[] or None
NOTES
AUTHOR: Michael Haken
LAST UPDATE: 1/22/2018
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$Arr = @(0x00, 0x00, 0x00, 0x01)
Remove-ByteArrayPadding -InputObject $Arr
The results of this cmdlet will produce a new array with contents @(0x01).
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>$Arr = @(0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF)
([ref]$Arr) | Remove-ByteArrayPadding -Padding 0xFF -FromEnd
This example demonstrates several things. First the input array can be passed by reference through the pipeline.
After the cmdlet complete, the variable $Arr will contain @(0x00, 0x00, 0x00, 0x01). The cmdlet specified the
padding
character to 0xFF and it removed the padding from the end of the array instead of the beginning.
RELATED LINKS