I'm used to Korn shell scripts and in korn, you can log within the scripts or the whole script itself.
ie.
#start log file
echo > c:\scripts\logfile.log
echo 'date' >> c:\scripts\logfile.log
copy file1 file2 >> c:\scripts\logfile.log 2>&1
echo "end script" >> c:\scripts\logfile.log
alternatively you can even do
myscript.ksh > c:\scripts\logfile.log
I can't to seem to do this in powershell. For example, I've created a simple function script that displays the computer name, windows name, service pack level and os version #.
From another script, i wanted to call this function and log the information.
ie.
$objLogFile = New-Item -type file "c:\scripts\logfile.log" -Force
GetComputerInfo | Out-File c:\scripts\logfile.log
The log file is empty.
I've tried
GetComputerInfo > c:\scripts\logfile.log
I get nothing.
I've looked at the start-transcript/end-transcript but that's like writing another script to log a script.
Thanks in advance!