Building long command pipelines is a very powerful way to express a complex action. Sometimes, though, we have to get the objects produced by a command somewhere in the middle of our pipeline and store them for future reference. The most common scenario is logging: we need to store a list of objects before acting on them. Say we want to terminate a couple of processes, but we need to write out the victim processes' names to an improvised audit log. Normally, we would get and terminate the processes using Get-Process and Stop-Process like this:
PS> Get-Process notepad | Stop-Process PS>
To write the objects that Get-Process returned to a file, we need to inject a Tee-Object call in the pipeline:
PS> Get-Process notepad | Tee-Object ...