* 配列に対して操作 - ForEach-Object [#s196ab73]
* 配列に対する操作 - ForEach-Object [#s196ab73]

** エイリアス [#n3147005]
 1,2,3 | ForEach-Object { New-Item -type f ([String] $_ + ".txt") }  
 1,2,3 | foreach { New-Item -type f ([String] $_ + ".txt") }  
 1,2,3 | % {  New-Item -type f ([String] $_ + ".txt") }  

 => 1.txt 
    2.txt 
    3.txt 
 
** Where-Objectと組み合わせて [#u44bffc0]
 1..6 | ? { $_ % 2 -eq 0 } | % { "DEBUG: " + $_ } 


 => DEBUG: 2 
    DEBUG: 4  
    DEBUG: 6

** Begin/Process/Endブロック [#sdcc4de7]
 dir *.txt | % -Begin { $sum = 0 } -Process { $sum += $_.length } -End { "File Size: " + $sum + " bytes" }

** 参考 [#if1cc9ad]
http://technet.microsoft.com/ja-jp/library/dd347608.aspx

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS