PowerShell script does not recognize path
Hello dear forum
I have written a PowerShell script which should automatically open the saved session and copy files from the source to the destination (Windows to Linux). New files are to be copied or revised, as the script will run every minute.
The connection can be established but then I get the error message:
What could be the cause? I can see the folder via the WinSCP GUI and the files in it are listed.
The script was tested in PowerShell ISE
I have written a PowerShell script which should automatically open the saved session and copy files from the source to the destination (Windows to Linux). New files are to be copied or revised, as the script will run every minute.
The connection can be established but then I get the error message:
Compare ... Local “remote” <= remote station “testfolder Error displaying the directory “remote\*.*”. Error retrieving the file list for “remote\*.*”.
The script was tested in PowerShell ISE
$winscpPath = "C:\Program Files (x86)\WinSCP\WinSCP.com" $sessionName = "testuser" $sourcePath = "C:\Users\test user\Documents\Test" $destinationPath = "/testfolder" $scriptPath = [System.IO.Path]::GetTempFileName() @" open $sessionName lcd "$sourcePath" cd "$destinationPath" synchronize -criteria=either -filemask="*>=1D" local remote exit "@ | Set-Content -Path $scriptPath & $winscpPath /script="$scriptPath" Remove-Item $scriptPath