PSObjectifier.psm1

#Takes non PSObjects such as System.DataRow and outputs as PSObject
Function PSObjectifier {
    [cmdletbinding()]
    Param(
        [parameter(
            Position = 0, 
            Mandatory = $true, 
            ValueFromPipeline = $true)]
        $data
    )
    Process {
        $properties = ($data | Get-Member -MemberType Property).name
        $array = @()
        ForEach ($row in $data) {
            $obj = New-Object psobject
            ForEach ($prop in $properties) {
                #DEBUG if($row.$($prop).GetType().name -eq "DBNull"){$row.$($prop) = ''}
                $obj | Add-Member -NotePropertyName $prop -NotePropertyValue $row.$($prop)
            }
            $array += $obj
        }
        $array
    }
}

Export-ModuleMember PSObjectifier