#1 07 Jun 2020 21:12

John Kumpf
Member
Registered: 07 Jun 2020
Posts: 1

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

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:

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,

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

Offline

Board footer

Powered by FluxBB