The below Powershell command will multiply three numbers and then add them up together.
First, let’s create the function which will do the multiplication job.
> function mul ($seed) { >> begin { $total = 0; $sum = 0; "All entries multiply by $seed" } >> process { $total = $seed * $_; "$_ multiplies by $seed is $total"; $sum += $total } >> end {"The total is $sum"} >> }
Next, try the above function out in your own Powershell console.
> 1..3 | mul 3
Which will produce the following outcomes:-
All entries multiply by 3 1 multiplies by 3 is 3 2 multiplies by 3 is 6 3 multiplies by 3 is 9 The total is 18
The process step of the function will display each step of the multiplication process.