Is there any difference between ForEach
and ForEach-Object
?
I have a small code like this, works fine
$txt = Get-Content 'C:emp00.txt'
$result = foreach ($line in $txt) {$line.replace(".ini","")}
$result | out-file 'c:emp01.txt'
But if i use 'ForEach-Object', I got errors....
$txt = Get-Content 'C:emp00.txt'
$result = foreach-object ($line in $txt) {$line.replace(".ini","")}
$result | out-file 'c:emp01.txt'
Why ? and how to output the loop results by using ForEach-Object
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…