LibraryInputComparison.ps1
## From Windows PowerShell Cookbook (O'Reilly) ## by Lee Holmes (http://www.leeholmes.com/guide) Set-StrictMode -Version 3 ## Process each element in the pipeline, using a ## foreach statement to visit each element in $input function Get-InputWithForeach($identifier) { Write-Host "Beginning InputWithForeach (ID: $identifier)" foreach($element in $input) { Write-Host "Processing element $element (ID: $identifier)" $element } Write-Host "Ending InputWithForeach (ID: $identifier)" } ## Process each element in the pipeline, using the ## cmdlet-style keywords to visit each element in $input function Get-InputWithKeyword($identifier) { begin { Write-Host "Beginning InputWithKeyword (ID: $identifier)" } process { Write-Host "Processing element $_ (ID: $identifier)" $_ } end { Write-Host "Ending InputWithKeyword (ID: $identifier)" } } |