Solved

Powershell 2.0 Write output to display and append to file

Posted on 2014-07-21
2
725 Views
Last Modified: 2014-07-21
Hi,

I would like to display a message in PowerShell and append the message to a log file.   In PowerShell 4.0 you can use Tee-Object -Append but I don't think they have the -Append option in PowerShell 2.0.    Is there an simple way to write a message to the screen and log file at the same time?   Thank you.

David

PS UnfortunatelyI can't upgrade to PowerShell 4.0.
0
Comment
Question by:davidst98
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
Comment Utility
What about using Add-Content with -PassThru switch? for example..
"Some data" | Add-Content c:\temp\log.txt -PassThru

Open in new window

0
 

Author Closing Comment

by:davidst98
Comment Utility
Thanks!   That works perfect.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
This article will help you understand what HashTables are and how to use them in PowerShell.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now