Topic "Syncronize Directories with Powershell - write log to file?"

Author Message
tredjejuni
[View user's profile]

Joined: 2016-03-06
Posts: 2
Hi,

I have got this powershell script example to work really great!
https://winscp.net/eng/docs/library_session_synchronizedirectories#powershell

But I would like the output information in a file in stead of on the screen.

I have tried almost everything in Powershell but without success. Only the last file transfer is seen in the file if I use
Code:
Write-Output ("Download of {0} succeeded" -f $e.FileName) > C:\backuptest\log.txt


How can I get the full log into the file? Preferrably a new line for each message. Question

Thanks for any advice![/code]
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
To append to a file, instead of overwriting it, use >> instead of the >:

Write-Output ("Download of {0} succeeded" -f $e.FileName) >> C:\backuptest\log.txt
tredjejuni
[View user's profile]

Joined: 2016-03-06
Posts: 2
prikryl wrote:
To append to a file, instead of overwriting it, use >> instead of the >:

Write-Output ("Download of {0} succeeded" -f $e.FileName) >> C:\backuptest\log.txt


Many Thanks!!! It worked great! Very Happy
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License