Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tee-Object and an -Append option

290 views
Skip to first unread message

Larry__Weiss

unread,
Apr 14, 2010, 4:49:43 PM4/14/10
to
The cmdlet Tee-Object has no -Append option for use when a file object is the
target to be written to.

There is an existing issue for this opened at connect.microsoft.com/PowerShell

https://connect.microsoft.com/PowerShell/feedback/details/137702

but is has been Closed (Won't Fix) with no comment justifying that action by
Microsoft.

Should we reinstate a request for a product change to add the -Append option to
the Tee-Object cmdlet?

- Larry

qa_warrior

unread,
Apr 14, 2010, 11:44:12 PM4/14/10
to

You could create a Proxy Function for Tee-Object and add this
functionality.

@lways

unread,
Apr 23, 2010, 8:32:04 AM4/23/10
to

You can use something like this

Write-output "Text" | %{out-host; out-file -filepath "$filename" -append}

"Larry__Weiss" wrote:

> .
>

Larry__Weiss

unread,
Apr 23, 2010, 11:41:52 AM4/23/10
to

Saving to a variable is the more general way to use Tee-Object.
Here's an example of appending to a file.

dir | tee-object -Variable tee
out-file tee.out -InputObject $tee -Append

- Larry

Larry__Weiss

unread,
Apr 23, 2010, 12:54:25 PM4/23/10
to
I am having trouble specifying a variable in the form of

${C:tee.out}

to Tee-Object.

dir | tee-object -Variable {C:tee.out}

won't work.

It just creates a variable named C:tee.out instead of
a file named C:tee.out

- Larry

0 new messages