Print custom output to file after X % to logfile

Advertisement

Ch33s3
Donor
Joined:
Posts:
10
Location:
World

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!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
34,328
Location:
Prague, Czechia

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?

Reply with quote

Ch33s3
Donor
Joined:
Posts:
10
Location:
World

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!

Reply with quote

Advertisement

You can post new topics in this forum