powershell pipeline

I have a script that combines some data and creates an output object on each pass through the results.
I'm attempting to utilize some of the functionality from this out-sql script: http://blogs.technet.com/b/sqlthoughts/archive/2008/10/03/out-sql-powershell-function-export-pipeline-to-a-new-sql-server-table.aspx

But, it's failing.

In my script, I have a function, Get-Logs, that produces output in the following format:
foreach ($item in $datacollection){ 
            $obj = new-object psobject
            $obj | Add-Member NoteProperty EntryDate $item.startdate
            $obj | Add-Member NoteProperty Username $item.User
           #...etc, etc...
            write-output $obj

Open in new window


I call this function piping it to the out-sql function:
get-logs | out-sql

That results in
out-sql : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and
its properties do not match any of the parameters that take pipeline input.

I've event attempted a simple out-test function that attempts to create the $properties variable.  If I step into this function, $_ and $properties are both empty...  What am I missing?
function out-test {
  $properties = $_.psobject.properties
}

Open in new window

LVL 67
sirbountyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
What if you have tried the examples from that site link? Is that still the same error?

If you understand this, you get to know whats wrong in your code:
You might be not producing the input what the out-sql is waiting to accept from your code:

http://richardspowershellblog.wordpress.com/2011/06/01/powershell-basics-4-pipeline/
0
sirbountyAuthor Commented:
the examples aren't quite applicable since I've modified the code somewhat.
Yet, as I said, even creating a test function to pipe the data to fails...
How can I ensure the function accepts the correct type of input?
0
sirbountyAuthor Commented:
I was able to get this to work by placing the properties declaration within the Process block...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sirbountyAuthor Commented:
Solved myself.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.