If it is a subdirectory, the function calls itself; if it is a file, it proceeds to download.
Loop through the list, identifying whether each item is a file or a subdirectory. powershell download ftp folder
Use ListDirectory or ListDirectoryDetails to get a list of all items in the remote folder. If it is a subdirectory, the function calls
For large folders, using the System.Net.WebClient class is often significantly faster than using Invoke-WebRequest because it avoids overhead from parsing HTML or other response data. Method 2: Using the WinSCP .NET Assembly (Recommended) If it is a subdirectory
Use System.Net.WebClient or FtpWebRequest with the DownloadFile method to transfer the data.
PowerShell FTP download files and subfolders - Stack Overflow