Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-SFTPChildItem does not list file if exact filename specified #598

Open
SCP002 opened this issue Oct 18, 2024 · 2 comments
Open

Get-SFTPChildItem does not list file if exact filename specified #598

SCP002 opened this issue Oct 18, 2024 · 2 comments

Comments

@SCP002
Copy link

SCP002 commented Oct 18, 2024

In v3.2.4, Get-SFTPChildItem no longer has -Name parameter and seems like we are supposed to specify file name in -Parh parameter.
However, if you run, for example:

Get-SFTPChildItem -SessionId $sess.SessionId -Path '/home/vlad/.xteve/backup/xteve_auto_backup_20241012_0405.zip'

It will respond with:

Write-Error: Error listing items in /home/vlad/.xteve/backup/xteve_auto_backup_20241012_0405.zip: Exception calling "ListDirectory"
with "1" argument(s): "No such file"

Such file definitely exist and in v3.2.3, if you pass file name with -Name parameter, it returns info about that file.

Note: If you add asterisk in the end of the file name like that:

Get-SFTPChildItem -SessionId $sess.SessionId -Path '/home/vlad/.xteve/backup/xteve_auto_backup_20241012_0405.zip*'

everything will work, but it's inconvenient.

@darkoperator
Copy link
Owner

as designs, the method for a session used is listdirectory() where the path to list all files is used. The call does not take a path to a file

@SCP002
Copy link
Author

SCP002 commented Oct 23, 2024

Thanks for your reply.
Understood, it works as intended.
Maybe we could have -Name parameter back to be able to to get info about specific file, so we dont have to use:

Get-SFTPChildItem -SessionId $sess.SessionId -Path '/path/to/dir' | Where-Object -Property 'Name' -Like 'the-name-i-want'

Anyway you can close this issue as completed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants