Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Ch33s3

sorry i might specified too much info here; the specific part below doesnt work, it simply doesnt print anything in my logfile (my guess is that -> if ($e.FileProgress -eq "(100%)") <-
is wrong ?

####
if ($e.FileProgress -eq "(100%)")
{
Write-Output ($e.FileName)(Get-Date -Format "HH:mm:ss") ("UPLOAD COMPLETE") | Out-File -FilePath $logPath\Sync_$Date.txt -Append
}
####

about the reduced logging, nope i didnt know that, but i already had a working (standard-) WinSCP log working in Powershell , so is there just a different kind of "$SessionLogPath" to be set? EDIT: I'm using 5.15.7.10060 - so that feature should be included i guess!
cheers!
martin

Re: Print custom output to file after X % to logfile

And what is wrong with your code?
Are you ware that recent versions of WinSCP have an optional reduced logging level?
Ch33s3

Print custom output to file after X % to logfile

Hi,
i'd like to make a custom (light) logfile which prints a log message (before and) after upload completion, maybe you could help me out ? (other messages in this script already work printing them to the light logfile so that part should be correct :) )
here's my current part;
function FileTransferProgress
{
param($e)

# New line for every new file
if (($script:lastFileName -ne $Null) -and
($script:lastFileName -ne $e.FileName))
{
Write-Host
}

# Print transfer progress
Write-Host -NoNewline (("`r{0} ({1:P0})") -f $e.FileName,$e.FileProgress)
#######THIS IS THE FAULTY PART#######
if ($e.FileProgress -eq "(100%)")
{
Write-Output ($e.FileName)(Get-Date -Format "HH:mm:ss") ("UPLOAD COMPLETE") | Out-File -FilePath $logPath\Sync_$Date.txt -Append
}
#####################################
# Remember a name of the last file reported
$script:lastFileName = $e.FileName
}
Cheers!