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!
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!