首先要安装模块 install-module transferetto
最低支持powershell5.1
先连接ftp看看。
$client=Connect-FTP -Server 'serverAddress' -Username 'userName' -Password 'password' -Port 8888
填上自己的地址和用户名,密码,端口就可以连上,端口是21,可以不填。
Disconnect-FTP -Client $client
连接sftp也很简单
$client=Connect-SFTP -Server '自己的sftp地址' -Username '用户名' -Password '密码'
Disconnect-SFTP -SftpClient $client
非常简单,强大吧,效率高。
得交待一句 执行这一句 $client.Encoding=[system.text.encoding]::Default
powershell 5.1 得到正确编码,powershell 7.2.1得到的是utf8编码,对于有些ftp系统来说,显示乱码。