You've already forked SharedScripts
mirror of
https://github.com/jaapbrasser/SharedScripts.git
synced 2026-06-14 00:14:16 +02:00
Added pipeline support and fixed padding 1️⃣1️⃣0️⃣1️⃣
This commit is contained in:
@@ -13,11 +13,13 @@ function ConvertTo-BinaryString {
|
|||||||
|
|
||||||
Take a string, converts it to a binary string and returns it as an array
|
Take a string, converts it to a binary string and returns it as an array
|
||||||
#>
|
#>
|
||||||
|
[cmdletbinding()]
|
||||||
param(
|
param(
|
||||||
|
[parameter(ValueFromPipeline)]
|
||||||
[string] $String,
|
[string] $String,
|
||||||
[switch] $ReturnArray
|
[switch] $ReturnArray
|
||||||
)
|
)
|
||||||
$Output = [int32[]]$String.tochararray() | ForEach-Object {[convert]::ToString($_,2).PadRight(8,0)}
|
$Output = [int32[]]$String.tochararray() | ForEach-Object {([convert]::ToString($_,2)).PadLeft(8,'0')}
|
||||||
|
|
||||||
if ($ReturnArray) {
|
if ($ReturnArray) {
|
||||||
return $Output
|
return $Output
|
||||||
|
|||||||
Reference in New Issue
Block a user