Downloading from SFTP Server

Advertisement

jrodriguez
Joined:
Posts:
1
Location:
Houston

Downloading from SFTP Server

My account has been setup on a SFTP Server where my home directory is set as root to a particular landing folder. My issue is in the script using $RemotePath = "/Home/username" this is not what it should be, I'm sure. I've tried using all listed below as the $remotePath, but still not working.
"/<root>"
"/"
"*"
""
"sftp://sftp.name.com"
Please advise on what my $remotePath should be if on the SFTP Server the home directory is set
to root?

Error below
PS D:\temp> D:\Scripts\HCM_Dowload.ps1
Exception calling "ListDirectory" with "1" argument(s): "Error listing directory 'sftp://sftp.******.com'.
General failure (server should provide error description).
Error code: 4
Error message from server: Folder not found: /sftp://sftp.******.com/
Common reasons for the Error code 4 are:
- Renaming a file to a name of already existing file.
- Creating a directory that already exists.
- Moving a remote file to a different filesystem (HDD).
- Uploading a file to a full filesystem (HDD).
- Exceeding a user disk quota."
At D:\Scripts\HCM_Dowload.ps1:44 char:9
+         $directoryInfo = $session.ListDirectory($remotePath)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SessionRemoteException
 
catch : The term 'catch' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path 
was included, verify that the path is correct and try again.
At D:\Scripts\HCM_Dowload.ps1:71 char:1
+ catch
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (catch:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 

    Write-Host "Error: $($_.Exception.Message)"
    #exit 1

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,378
Location:
Prague, Czechia

Re: Downloading from SFTP Server

Use the path you see on the top of the file panel in WinSCP GUI, when you login to the server. So if I understand you correctly, it should be "/". You can also use $session.HomePath.
If you still have problems, we need a session log file.

Reply with quote

Advertisement

You can post new topics in this forum