From the course: PowerShell: Functions for Advanced Automation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Accept pipeline input

Accept pipeline input

From the course: PowerShell: Functions for Advanced Automation

Start my 1-month free trial

Accept pipeline input

- (Instructor) The parameters that you specify in the beginning of a PowerShell function may come from user input. But that may not always be the case. Sometimes you'll create a function to process a long list of objects. Or at other times, you'll create and schedule scripts that automate processes that need to pull the parameters from other locations. In either of these last 2 situations, you'll benefit from the option to accept Parameter Input from The Pipeline. If you've been using PowerShell for a while, you should be familiar with the concept of The Pipeline. Objects are gathered or processed by one Command Letter function, and then passed along to another. You can define a Parameter Attribute, so that your function can accept specific arguments from that pipeline. Here's the function that we created previously. All it does is define a Parameter that can be entered at the prompt. Let's say we wanted to accept a long list of employees and work with just their Employee ID numbers…

Contents