an RTM updated version of the out-dataTable script for RC2
( return datatable needs to be wrapped otherwise returned as array of datarows )
you can find this and more datasetutilities along with information and links to usage example (CSV series ) here :
[url:http://mow001.blogspot.com/2006/05/powershell-out-datagrid-update-and.html]
{{
# Function out-dataTable
# converts piplineinput into a dataTable
# /\/\o\/\/ 2006
# http:\\thePowerShellGuy.com
Function out-DataTable {
$dt = new-object Data.datatable
$First = $true
foreach ($item in $input){
$DR = $DT.NewRow()
$Item.PsObject.properties | foreach {
If ($first) {
$Col = new-object Data.DataColumn
$Col.ColumnName = $_.Name.ToString()
$DT.Columns.Add($Col) }
if ($_.value -eq $null) {
$DR.Item($_.Name) = "[empty]"
}
ElseIf ($_.IsArray) {
$DR.Item($_.Name) =[string]::Join($_.value ,";")
}
Else {
$DR.Item($_.Name) = $_.value
}
}
$DT.Rows.Add($DR)
$First = $false
}
return @(,($dt))
}
}}
Greetings /\/\o\/\/