powershell : ftp directory listing (help on a script) powershell : ftp directory listing (help on a script) powershell powershell

powershell : ftp directory listing (help on a script)


First you should retrieve all the data

Replace the method with this

$ftp.Method = [System.Net.WebRequestMethods+FTP]::ListDirectoryDetails

Without the details you only get the filenames.

To download a file I usually use the webclient class

$webclient = New-Object System.Net.WebClient$webclient.credentials = New-Object System.Net.NetworkCredential("anonymous","anonymous@test.com")$webclient.downloadfile("ftp://ftp.host.com/file.txt", "c:\temp\file.txt")

Downloadfile method of the webclient class