Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Piplelines with and without Foreach cmdlet

$
0
0

A question about the pipleline and foreach

Say I have the below 2 patterns of PowerShell pipeline syntax:

cmdlet1 | cmdlet2 



cmdlet1 | foreach {cmdlet2} 


How do I intuitively decide which one among the above two to go for while addressing a problem?

For example, with get-content import-csv we use foreach cmdlet but with get-aduser and set-aduser we do not. My question is what is the science here that distinguishes the 2 usage patterns.



Hope my question makes sense.

Thanks in advance








Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>