【发布时间】:2015-02-05 16:47:49
【问题描述】:
我正在尝试通过 PowerShell 脚本从我的 FTP 服务器获得响应。为此,我编写了以下内容:
$sourceuri = "<string>"
$targetpath = "<string>"
$username = "<string>"
$password = "<string>"
# Create a FTPWebRequest object to handle the connection to the ftp server
$ftprequest = [System.Net.FtpWebRequest]::create($sourceuri)
# set the request's network credentials for an authenticated connection
$ftprequest.Credentials = New-Object System.Net.NetworkCredential($username,$password, $sourceuri)
$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile
$ftprequest.UseBinary = $true
$ftprequest.KeepAlive = $false
# send the ftp request to the server
$ftpresponse = $ftprequest.GetResponse()
执行脚本时,它返回错误 530,表示我没有登录。我没有 PowerShell 经验,不确定需要添加什么来修复此错误
【问题讨论】:
标签: powershell ftp