Public/Add-DataTable.ps1
function global:Add-DataTable { <# .EXTERNALHELP HelperFunctions.psm1-Help.xml #> [CmdletBinding()] [Alias('Make-Table','fnMake-Table')] [OutputType([System.Data.DataTable])] param ( [Parameter(Mandatory = $true, Position = 0)] [ValidateNotNullOrEmpty()] [String]$TableName, [Parameter(Mandatory = $true, Position = 1)] [ValidateNotNullOrEmpty()] $ColumnArray ) Begin { $null = $dt $dt = New-Object System.Data.DataTable("$TableName") } Process { ForEach ($col in $ColumnArray) { [void]$dt.Columns.Add([System.Data.DataColumn]$col.ColumnName.ToString(), $col.DataType) } } End { Write-Output @(,$dt) } } #end function Add-DataTable |