Solved

Powershell 2.0 Write output to display and append to file

Posted on 2014-07-21
2
831 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 40210239
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
ID: 40210250
Thanks!   That works perfect.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

635 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