CleanCode logo
sitemap
SEARCH:

CleanCode PowerShell Libraries v1.2.05 API: CleanCode » SqlTools » Out-DataTable

Out-DataTable

NAME

Out-DataTable

SYNOPSIS

Creates a DataTable for an object.

SYNTAX

Out-DataTable [-InputObject] <PSObject[]> [-TypeFilter <String>] [<CommonParameters>]

DESCRIPTION

Creates a DataTable based on an object's properties. (Based on Chad Miller's original work--see Links section.)

PARAMETERS

-InputObject <PSObject[]>

        Specifies the objects to be converted to a DataTable.
        If an array of objects is passed, any with a type that differs 
        from the first object in the list are ignored and a warning is displayed.
        To suppress the warning, use the TypeFilter parameter to pre-filter the list to a single type.

        Required?                    true
        Position?                    1
        Default value                
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false

-TypeFilter <String>
        Specifies a selection filter by data type name.
        If not specified, all objects are processed and those with differing types
        generate a warning message.
        If TypeFilter is specified, only those objects matching the type name are processed.

        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

<CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, see 
        about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 

INPUTS

Object. Any object can be piped to Out-DataTable.

OUTPUTS

System.Data.DataTable

NOTES


        Adapted from script by Marc van Orsouw see link 
        Version History 
        v1.0  - Chad Miller - Initial Release 
        v1.1  - Chad Miller - Fixed Issue with Properties 
        v1.2  - Chad Miller - Added setting column datatype by property as suggested by emp0 
        v1.3  - Chad Miller - Corrected issue with setting datatype on empty properties 
        v1.4  - Chad Miller - Corrected issue with DBNull 
        v1.5  - Chad Miller - Updated example 
        v1.6  - Chad Miller - Added column datatype logic with default to string

EXAMPLES

-------------------------- EXAMPLE 1 --------------------------
C:\PS>$dt = Get-PsDrive | Out-DataTable

This example creates a DataTable from the properties of Get-PsDrive and assigns output to the $dt variable.

-------------------------- EXAMPLE 2 --------------------------
C:\PS>$dt = Get-ChildItem | Out-DataTable -TypeFilter FileInfo

This example creates a DataTable selecting only those objects that have type FileInfo (i.e. ignoring those of type DirectoryInfo, the other object output by Get-ChildItem).

RELATED LINKS

This documentation set was created with CleanCode's DocTreeGenerator.

Valid XHTML 1.0!Valid CSS!Get CleanCode at SourceForge.net. Fast, secure and Free Open Source software downloads
Copyright © 2001-2014 Michael Sorens • Contact usPrivacy Policy
Usage governed by Mozilla Public License 1.1 and CleanCode Courtesy License
CleanCode -- The Website for Clean DesignRevised 2014.07.15