I am working on a fairly small script that aims to download all files from a FTP folder. The script is a powershell script and uses the PSFTP module. So for test purposes I created 3 randoms files in the ftp folder called "a", "b" and "c".
The script works like this
- Creating PSCredentials
- Creating a FTP connection
- Connecting to session
- Downloading all files from the root ftp folder
So, all is working except the last line. To take all files i try using the wildcard * but this creates an error : Exception calling ".ctor" with 2 argument(s)
The whole script looks like this :
Import-Module PSFTP
$pass = ConvertTo-SecureString "1234" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ('...2', $pass)
Set-FTPConnection -Credentials $cred -Server ... -Session CertFTP -IgnoreCert -UseBinary -KeepAlive
$Session1 = Get-FTPConnection -Session CertFTP
Get-FTPItem -Path * -LocalPath 'C:\Certificats' -Session $Session1
I tried the same thing but with -Path "a", and this is working. Thus, what I don't know is : Am I doing something wrong in the syntax itself, or does Get-FTPItem doesn't support using * in -Path?