You've already forked SharedScripts
mirror of
https://github.com/jaapbrasser/SharedScripts.git
synced 2026-04-18 19:01:56 +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
|
||||
#>
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[parameter(ValueFromPipeline)]
|
||||
[string] $String,
|
||||
[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) {
|
||||
return $Output
|
||||
|
||||
Reference in New Issue
Block a user