Select and Where via Pipeline on Custom Function
-
Thursday, June 21, 2012 5:39 PM
I have a function that collections a large amount of data and the end result is a Table Object.
This function requires the usage of a Web-Proxy inside, thus we would like to not store the function in a variable and then perform a select or where.
What is the recommended approach to enable my function to support select and where, while running the function with out it being a stored variable?
For example if there are two columns one Idle Status and Document count, I wish to perform this on the pipeline.
End goal is that we will put this into a Do or While.
Windows Server 2008 Field Readiness / Marketing Lab Manager
All Replies
-
Thursday, June 21, 2012 5:45 PMWhen you say 'table' object what is the exact datatype? Are we talking about an ADO.NET DataSet?
-
Thursday, June 21, 2012 5:51 PMSystem.Data.DataTable. Could I switch to a filter function instead?
Moved On
- Edited by AJ Lambert Thursday, June 21, 2012 5:53 PM
-
Thursday, June 21, 2012 5:54 PM
Although this is a DataSet it may help you get where you need to go:
http://learningpcs.blogspot.com/2010/10/powershell-sql-dataset.html
-
Thursday, June 21, 2012 6:13 PM
Hmm not sure that's what I am looking for.
How would I do something like Get-Status | ? {$_.'Idle Status" -eq "idle"} or Get-Status | ? {$_.'Collection Name" -eq "Temp-Name"}
These are columns that get defined inside the function.
It sounds like I need to split my function up.
1. Function to Generate Table
2. Pass Table to the Data Gathering portion as a new function that accepts the table as input. I assume that since the table is built in the function that the pipeline would not be able to take action against this.
Moved On
-
Thursday, June 21, 2012 8:13 PM
Anyone looking for an answer on this
The returned variable must have $script: added to the variable. This allowed me to perform Where and Select on the pipeline.
Moved On
-
Tuesday, June 26, 2012 7:28 AM
Your description is (at least for me) hard to follow.
Not sure what you mean by "support where and select" and also not sure why you mention variable in the same context: both cmdlets work perfectly in pipeline. Without knowing what you want to use select/ where for and when you want to use it - we can't really help you. Possible scenarios:
- function should be fine with foo | where { } | select alfa, beta | Your-Function
- other way around: foo | Your-Function | where {} | select
- function should be able to do foo | Your-Function with ability to filter (where) and narrow the results (select) internally
Some code would be more than welcome. Also end result. Without it - it's not possible to give any answers IMO.

