Various technical articles, IT-related tutorials, software information, and development journals
Saturday, March 10, 2018
Piping arrays to functions might not work as expected
PowerShell functions can include a Param block to gain more control over how they accept input. They can accept data from the pipeline by including a ValueFromPipeline parameter, for example. I found, however, that this tends not to work well with arrays. The function gets an array containing a single element: the first one in the original array. Using advanced functions could probably make accepting lists of things work better, but I found it easier to just accept the array as a normal parameter, which works as expected.
Labels:
windows
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment