Getting significant bytes

by May 5, 2011

If you need to split a decimal into bytes, you can use  a function called ConvertTo-HighLow, which uses a clever combination of type casts to get you the high and low bytes:

function ConvertTo-HighLow {
  $result = [System.Version][String]([System.Net.IPAddress]$number) 
  $newobj = 1 | Select-Object Low, High, Low64, High64
  $newobj.Low = $result.Major
  $newobj.High = $result.Minor
  $newobj.Low64 = $result.Build
  $newobj.High64 = $result.Revision



Twitter This Tip!
ReTweet this Tip!