Some examples of using NetCmdlets in PowerShell. The FTP NetCmdlet supports plain and secure (both SSL and SSH) FTP connections right from the PowerShell console.
List files on a remote server:
PS C:\> get-ftp -server myserver -user lancer -password mypass
The same, but using SSL (auth-tls):
PS C:\> get-ftp -server myserver -user lancer -password mypass -ssl explicit
And again, but using SSH 2.0:
PS C:\> get-ftp -server myserver -user lancer -password mypass -ssh
Find the files on a remote server that are larger than 10 Megs:
PS C:\> get-ftp -server myserver -user lancer -password mypass| where { $_.FileSize -gt 10MB }
Delete a file on a remote FTP server:
send-ftp -server myserver -user lancer -password mypass -delete filetodelete.txt
Delete all files on a remote FTP server that are greater than 10 Megs:
PS C:\>get-ftp -server myserver -user lancer -password mypass | where { $_.FileSize -gt 10MB } | foreach-object -process {send-ftp -server myserver -user lancer -password mypass -delete $_.FileName}
Calculate the number of bytes in the files of a remote server directory:
PS C:\> get-ftp -server myserver -user lancer -password mypass -path / | measure-object -property FileSize -sum
Find all the local .txt files and upload them to a remote FTP server:
PS C:\> get-childitem *.txt | select Name | set-ftp -server myserver -user lancer -password mypassword -localfile $_ -remotefile $_
Technorati : FTP, FTPS, NetCmdlets, SFTP, cmdlet, powershell