Tee-Object now takes -Append as of ps v3.0

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

Tee-Object now takes -Append as of ps v3.0

Post by MigrationUser »

07 Jun 2020 21:12
John Kumpf

SS64.com is so helpful!!!

I was just working with Tee-Object in powershell: ss64.com/ps/tee-object.html (I'm not allowed to post links--just joined)

Apparently Powershell 3.0 added an -Append switch.

It would be greatly helpful to the many happy users of ss64 (including me) to include this new switch in the documentation here.

I found out about -append here: stackoverflow.com/questions/15696976/powershell-tee-object-without-overwriting-file

For clarity, Tee-Object by default overwrites the output. So:

Code: Select all

write-output "line 1" | Tee-Object $outfile
write-output "line 2" | Tee-Object $outfile
would overwrite line 1 with line 2 and $outfile would just contain line 2 at the end.

Whereas,

Code: Select all

write-output "line 1" | Tee-Object -Append $outfile
write-output "line 2" | Tee-Object -Append $outfile 
would write both line 1 and line 2 to the outfile

----------------------------

Today 10:35
Simon Sheppard


Thanks John, now added

https://ss64.com/ps/tee-object.html
Post Reply