Topic "Powershell - SynchronizeDirectories - The argument is null or empty"

Author Message
Kilsgaard
[View user's profile]

Joined: 2016-10-11
Posts: 4
Location: Silkeborg, Denmark
Hi

Can anyone give me an idea how to solve this?

I get the following error when i syncronize to or from my ftp with a powershell script, build on the template.
"The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."

It looks like it is when there is no files to syncronize, but should: $synchronizationResult.IsSuccess be $false if there is no files that have been syncronized?
I am using the $synchronizationResult to move or removed syncronized files.

Can anyone tell me if there is any other trick to test if the $synchronizationResult is empty?

Code:
   
try
{
    $session.Open($sessionOptions)

    $transferOptions = New-Object WinSCP.TransferOptions
    $transferOptions.FileMask       =  "|*/"
    $transferOptions.OverwriteMode  =  [WinSCP.OverwriteMode]::Overwrite
    $transferOptions.TransferMode   =  [WinSCP.TransferMode]::Binary

    $synchronizationResult = $session.SynchronizeDirectories(
    [WinSCP.SynchronizationMode]::Local, $localPath, $remotePath, $False, $False, [WinSCP.SynchronizationCriteria]::None, $transferOptions)

    if ($synchronizationResult.IsSuccess -eq $true)
    {
       foreach ($download in $synchronizationResult.Downloads)
       {


Thanks on advance
/Graves
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27106
Location: Prague, Czechia
Kilsgaard wrote:
I get the following error when i syncronize to or from my ftp with a powershell script, build on the template.
"The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."

Where do you get the error? On what command? Is this really a full error message? Doesn't it name the argument?
I cannot reproduce the problem with your code.

Quote:
but should: $synchronizationResult.IsSuccess be $false if there is no files that have been syncronized?

Where there are no files to synchronize, the IsSuccess is $True.
Kilsgaard
[View user's profile]

Joined: 2016-10-11
Posts: 4
Location: Silkeborg, Denmark
Hi

Thanks for your answer Smile

I have solved the problem, it was one of the winscp variables that I accedentialy set to an empty value Sad
Advertisements

You can post new topics in this forum

Search

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