Lessons Learned

My drop-site for interesting snippets and tips. If it's useful to you as well, great!

Browse by Tags

Tagged Content List
  • Blog Post: Left-Padding a String

    I’ll be honest; .NET has more methods and classes and properties than I can shake an idiom at. In my previous blog post, I needed to left-pad a string with zeroes in order to treat it as a 32-bit binary value to [Array]::Reverse() . I also had to do the same for an 8-bit value, but the method is the...
  • Blog Post: One-Liner: Left-Padding a String with Zeroes

    Yesterday’s post had a little bit of sleight-of-hand involved.  For the IPv4 address to UInt64 conversion to work, each octet had to be converted into an 8-character string of ones and zeroes.  However, [convert]::ToString($int, 2) doesn’t zero pad, and this is now a string, not an Int, so...
  • Blog Post: Regular Expressions, Search-and-Replace Interpolation and Delegates

    This (and the previous post) stem from me stumbling onto this page: http://stackoverflow.com/questions/17229866/powershell-hex-to-string-conversion/19151495 Last time, we looked at hex-decoding a string. In the above, the original poster had file of space-delimited lines, each with three fields...
  • Blog Post: Splitting a Hex-Encoded String into Pairs of Hex Characters (a.k.a. To Pull a Noah)

    Simple enough task: I have a hex-encoded string and need to decode it.  Now, we all know that to en code a string to hex is to cast each [char] to [int], then shove it through the "{0:X}" format specifier, then concatenate all the strings. $string = "The quick brown dog"; [string...
  • Blog Post: PowerShell for Non-N00bs: Formatting Time With RegEx

    So, last episode we learned how to format the output of a LastBootUpTime property from the WIN32_OperatingSystem WMI query to something human readable using WMI. What if that didn't exist? PSH> (Get-WmiObject -Query 'SELECT LastBootUpTime FROM Win32_OperatingSystem').LastBootUpTime 20090712112652...
  • Blog Post: PowerShell for Non-N00bs: How Much is That Character in the Window? (Or, How to Change Your Password Without Really Trying)

    I'm creating a slightly different track here. PowerShell for Non-N00bs is for me to track some of the tidbits I've found along the way. This will be a two-fer article. By this I mean I'm going to address two tangentially related subjects: how to find an 'odd' character that is visible, but not matching...
Page 1 of 1 (6 items)