psftp上传文件到服务器,使用PsFtp将文件上传到FTP Powershell
我在這個問題上一直在抨擊我的大腦,似乎無法修復它。我正在嘗試使用PSFTP將文件上傳到FTP。
我正在使用的腳本:
#------------------------------------------------------
#local variables
$ftp_server = "SERVERNAME"
$ftp_path = "/FTPPATH/PATH"
$local = "C:\ftp\"
$local_in = Join-Path $local "In"
$local_out = Join-Path $local "Out"
$session = "my_ftp_session"
# set up credentials object
$username = "FFandP"
$password = Get-Content "$local_out\Credentials.txt" | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password
Set-FTPConnection -Server $ftp_server -Credentials $cred -Session $session -KeepAlive -confirm -UseBinary
Get-ChildItem -Path $local_out |
% {
$ftp_file = "$ftp_path/$($_.Name)" # determine item fullname
Add-FTPItem -Path $ftp_file -LocalPath $_.FullName -Session $session -
}
# -------------------------------------------------
我收到錯誤:
Add-FTPItem : Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (550) File
unavailable (e.g., file not found, no access)."
At line:22 char:1
+ Add-FTPItem -Path $ftp_file -LocalPath $_.FullName -Session $session
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Add-FTPItem
我已嘗試自行運行Add-FTPitem命令,但我收到同樣的錯誤。
我可以使用FileZilla上傳到FTP。我也嘗試刪除變量并使用硬編碼路徑;我得到了同樣的錯誤。
有什么想法嗎?
總結
以上是生活随笔為你收集整理的psftp上传文件到服务器,使用PsFtp将文件上传到FTP Powershell的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《鸟哥的linux私房菜-服务器篇 第三
- 下一篇: JVM JRE JDK,这些东西到底是什