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

Re: Directory Synchronization - System cannot find the path specified

This is not WinSCP question.
It's your PowerShell code that is wrong.
This is not a correct way to pass two parameters to a PowerShell function:
Synchronize-Directory($directoryPair[0], $directoryPair[1])

Drop the brackets and the comma. This is the correct way:
Synchronize-Directory $directoryPair[0] $directoryPair[1]
dkimmo

Directory Synchronization - System cannot find the path specified

$directoryPaths = @()
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\apis"), "/var/www/html/apis"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\bobbin"), "/var/www/html/bobbin"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\cloud"), "/var/www/html/cloud"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\components"), "/var/www/html/components"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\css"), "/var/www/html/css"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\fonts"), "/var/www/html/fonts"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\functions"), "/var/www/html/functions"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\images"), "/var/www/html/images"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\includes"), "/var/www/html/includes"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\pterodactyl"), "/var/www/html/pterodactyl"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\scripts"), "/var/www/html/scripts"))
    $directoryPaths += (, ($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\..\utils"), "/var/www/html/utils"))
# Synchronize directories
function Synchronize-Directory($localPath, $remotePath)
{
    $synchronizationResult = $session.SynchronizeDirectories(
        [WinSCP.SynchronizationMode]::Remote, $localPath, $remotePath, $False)
    $synchronizationResult.Check()
}
foreach ($directoryPair in $directoryPaths)
{
    Synchronize-Directory($directoryPair[0], $directoryPair[1])
}

Getting this error with the above code:
Error: Exception calling "Check" with "0" argument(s): "Error listing directory 'C:\Users\me\Desktop\work\...\apis /var/www/html/apis\*.*'.

Error retrieving file list for "C:\Users\me\Desktop\...\apis /var/www/html/apis\*.*".
System Error.  Code: 3.
The system cannot find the path specified"

Not sure why because it works fine when I synchronize the directories through the WinSCP GUI application... I also tried adding an extra / to the end of the second directory path which still failed.