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: 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 Gotchas: Looping with $null

    For some obscene reason, PSHv1 will gladly iterate with a $null as an array element in Foreach. @( $null , 1, $null , 2) | Foreach { "'$_'" ; } '' '1' '' '2' So, in the name of defensive programming, I've taken to manually testing for this case: @( $null , 1, $null , 2) | Foreach { if ( ...
  • Blog Post: PowerShell for N00bs 4: More Properties than a Monopoly Board

    We used Select-Object -Property to, well, select properties (after all, PowerShell is trying to move away from obscure abbreviations and truncated names.) How do we know what properties exist? Get-Member . We covered this in N00bs 2. Get-Member gets the ... class members of a PowerShell object...
Page 1 of 1 (3 items)