2
votes
closed
out-dataTable

Description

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\/\/

File Attachments

No files are attached

Closed Feb 2 2007 at 3:49 AM by staceyw

Comments


Updating...
© 2006-2010 Microsoft | Get Help | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2010.7.20.17027