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

martin

gothbox wrote:

But does anyone know if there is possible to log the size of the files transferred ?

Well, it's your local files, so you can query their size. Transfer size is the same (as you use binary mode transfer).
gothbox

as far as i understand i need to log to XML file, but im unsure if i need something more to log size of files transferred.

Anyone ?
gothbox

Figured it out :)

Had to put $session = New-Object WinSCP.Session before $session.SessionLogPath = "\\***\Log\Uploaded.log" and it worked :)

But does anyone know if there is possible to log the size of the files transferred ?
gothbox

Unable to log output from powershell script.

Hi all!

I'm really new to powershell, and need some help figuring out why this script fails.

Here's the script:

try
{
# Load WinSCP .NET assembly
[Reflection.Assembly]::LoadFrom("WinSCPnet.dll") | Out-Null

# Setup session options
$SessionOptions.DisableVersionCheck
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "***"
$sessionOptions.UserName = "***"
$sessionOptions.Password = "***"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 ***"
$session.SessionLogPath = "\\***\Log\Uploaded.log"
$session = New-Object WinSCP.Session

try
{
$session.ExecutablePath = "D:\Program Files (x86)\WinSCP\winscp.exe"
# Connect
$session.Open($sessionOptions)

$localPath = "\\***\testwebexp*.txt"
$remotePath = "/**/out/"
$backupPath = "\\***exp\processed\"

# Upload files, collect results
$transferResult = $session.PutFiles($localPath, $remotePath)

# Iterate over every transfer
foreach ($transfer in $transferResult.Transfers)
{
# Success or error?
if ($transfer.Error -eq $Null)
{
Write-Host ("Upload of {0} succeeded, moving to backup" -f
$transfer.FileName)
# Upload succeeded, move source file to backup
Move-Item $transfer.FileName $backupPath
}
else
{
Write-Host ("Upload of {0} failed: {1}" -f
$transfer.FileName, $transfer.Error.Message)
}
}
}
finally
{
# Disconnect, clean up
$session.Dispose()
}

exit 0
}
catch [Exception]
{
Write-Host $_.Exception.Message
exit 1
}


The script works well when i remove the line :
$session.SessionLogPath = "\\linux1\v\prod\dataexch\no2\vismaservicessere\exp\Log\Uploaded.log"


But when i try to run it with the løine it fails with this error:
The property 'SessionLogPath' cannot be found on this object. Verify that the property exists and can be set.


These's somewhere where i need to include this, but im do dumt to figure it out myself.
Could anyone please give me a helping hand ?