Problem
Your function primarily takes its input from the pipeline, and you want it to perform the same steps for each element of that input.
Solution
To write a pipelineoriented function, define your function using the filter keyword, rather than the function keyword. PowerShell makes the current pipeline object available as the $_ variable.
filter GetPropertyValue($property)
{
$_.$property
}
Discussion
Afilter is the equivalent of a function that uses the cmdletstyle keywords and has all its code inside the process section.
The solution demonstrates an extremely useful filter: one that returns the value of a property for each item in a pipeline:
PS >GetProcess | GetPropertyValue Name audiodg avgamsvr avgemc avgrssvc avgrssvc avgupsvc (...)
Lists, Arrays, and Hashtables
Most scripts deal with more than one thing—lists of servers, lists of files, lookup codes, and more. To enable this, PowerShell supports many features to help you through both its language features and utility cmdlets.
PowerShell makes working with arrays and lists much like working with other data types: you can easily create an array or list and then add or remove elements from it. You can just as easily sort it, search it, or combine it with another array. When you want to store a mapping between one piece of data and another, a hashtable solves that need perfectly.