#test array
$comp = New-Object System.Object
$comp | Add-Member -type NoteProperty -name DSAType -value "xtra"
$comp | Add-Member -type NoteProperty -name Hostname -value "Host"
$comp | Add-Member -type NoteProperty -name Fails -value "failures"
#foreach ($comp in $warrantarray){
$cl=$null
$dl=$null
($comp|gm)|where{$_.membertype -eq 'noteproperty'}|% {
$cl+=$_.Name+","
$dl+=($comp).($_.name)+","
}
$cl=$cl.Substring(0,$cl.Length-1)
$cl
$dl=$dl.Substring(0,$dl.Length-1)
$dl
# do sql stuf... but write-hosting here...
write-host "INSERT INTO $dbTable ($cl) VALUES ($dl)"
#}
also possible to this way.http://sphints.blogspot.com.au/2014/03/powershell-write-array-of-objects-to.html
No comments:
Post a Comment