Hex-Decimal-Convert.psm1
<#
=========================================================================== Created by: Rhys M Contact: RhysM.PS@gmail.com PS Gallery: https://www.powershellgallery.com/profiles/RhysM/ Filename: Hex-Decimal-Convert.psm1 ------------------------------------------------------------------------- Module Name: Hex-Decimal-Convert =========================================================================== #> function Hex-To-Decimal { Param ( $Hex ) $DataOutput = @() foreach ($Item in $Hex){ $ItemUpdated = "$Item" -replace '#',"" $Object = [PSCustomObject]@{ Hex = $ItemUpdated Decimal = [Convert]::ToInt64($ItemUpdated,16) } $DataOutput += $Object } $DataOutput } function Decimal-To-Hex { Param ( $Decimal ) $DataOutput = @() foreach ($Item in $Decimal){ $HexSTR = [System.String]::Format('{0:X}', $Item) if ($HexSTR.length -eq 5){ $HexResult = "0" + $HexSTR } elseif ($HexSTR.length -eq 4){ $HexResult = "00" + $HexSTR } else{ $HexResult = $HexSTR } $Object = [PSCustomObject]@{ Decimal = $Item Hex = $HexResult } $DataOutput += $Object } $DataOutput } Export-ModuleMember -Function Hex-to-Decimal, Decimal-To-Hex |