Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Trying to output to both screen and file, but tee-object doesn't seem to be the correct answer.

$
0
0

Ok, folks, forgive me for being new, but I vowed during the "Basic A" days to never do ANY programming, but here I am.

My question is:

I want to output a text string "##############" (as a seperator) to a log file and the screen, I also want to output other string data with variable information. "processessing $computer - "

I have tried to use out-file, write-output, tee-object, write-host and can't seem to get my junk straight, so I need some basic help.

of course a lot of my script is "FRANKENSCRIPT", but it's essentially working fine. I would be afraid to post it as it would probably garner a lot of giggles and maybe scare some people.

ok, fine, here is a clip.

foreach ($server1 in $servers)
   
    {write-host "#########################################"
    $server1 | out-file -filepath $log -append
    write-host "`n"
    write-host "Working with server $server1"

of course it doesn't work.

thanks in advance.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>