# encoding: ascii
# api: powershell
# title: h20 -Hashtables 2 object
# description: hashtable to object function.
# version: 0.1
# type: function
# author: nQPuDDji
# license: CC0
# x-poshcode-id: 2697
# x-archived: 2016-05-19T15:22:19
# x-published: 2012-05-27T11:44:00
#
# used to be able to make custom objects with math inside the pipeline
#
#hashtable to object function.
#used to be able to make custom objects with math inside the pipeline 
#e.g. 1..10 | h20 { @{karl = $_;dude = $_+1} }
#gps | h20 { @{name = $_.processname; mem = $_.workingset / 1MB} }
function h20([scriptblock]$sb )
{
 begin {}
 process{ if ($sb -ne $null)
                {
                  $ht = &$sb;
                  if ($ht -is [hashtable])
                    {
                        New-Object PSObject -Property $ht}
                    }
                  if ($ht -is [object[]])
                    {
                    $ht | % { New-Object PSObject -Property $_ }
                    }  
                }
            
 end{}
}
