Link to home
Create AccountLog in
Avatar of sirbounty
sirbountyFlag for United States of America

asked on

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:

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 = $

Open in new window

Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

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:
Avatar of sirbounty


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?
Avatar of sirbounty
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Solved myself.