Created
September 5, 2014 12:05
-
-
Save guitarrapc/61efd5baa445ece62504 to your computer and use it in GitHub Desktop.
PowerShell Pipeline Programming Style sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function PipelineExecuteOnEndProcessingStyle | |
{ | |
param | |
( | |
[parameter(Position = 0, Mandatory = 1, ValueFrompipeline = 1, ValueFromPipelineByPropertyName = 1)] | |
[string]$hostaddress | |
) | |
begin{ $hostaddresses = @() } | |
process | |
{ | |
# まとめる | |
foreach ($h in $hostaddress){ $hostaddresses += $h } | |
} | |
end | |
{ | |
# まとめてとばす | |
Execute; | |
} | |
} | |
function PipelineExecuteOnEveryProcesseingStyle | |
{ | |
param | |
( | |
[parameter(Position = 0, Mandatory = 1, ValueFrompipeline = 1, ValueFromPipelineByPropertyName = 1)] | |
[string]$hostaddress | |
) | |
begin{ $hostaddresses = @() } | |
process | |
{ | |
# 毎回の入力でとばす | |
foreach ($h in $hostaddress) {$hostaddresses += $h; Execute; } | |
} | |
} | |
function Execute | |
{ | |
# なんか処理 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment