$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])
}
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.