【问题标题】:Error 530 upon FTP Request with PowerShell使用 PowerShell 进行 FTP 请求时出现错误 530
【发布时间】: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


    【解决方案1】:

    问题可能出在这一行

    $ftprequest.Credentials = New-Object System.Net.NetworkCredential($username,$password, $sourceuri)
    

    [System.Net.NetworkCredential] 的唯一 constructor that accepts 3 parameters 正在寻找用户名、密码、。你有$sourceuri domain.$sourceuri 是FTP url,不是吗?我应该认为,如果您只是使用基本的 FTP 凭据,您只需要拥有用户名和密码。

    $ftprequest.Credentials = New-Object System.Net.NetworkCredential($username,$password)
    

    【讨论】:

    • $sourceuri 是我相信的字符串。取出 $sourceuri 将错误更改为 550 错误,我不知道如何修复
    • @NickG 这只是意味着权限被拒绝。 $sourceuri 的网址是否正确?您可以在浏览器中使用这些凭据吗?它是否使用域凭据?
    • 凭证在浏览器中工作。我刚刚运行了另一个脚本,该脚本列出了我的 shell 中的目录并且有效。但是下载脚本会抛出 550 错误
    • 我使用的是 Windows Server 2012,我该去哪里验证 FTP?
    猜你喜欢
    • 2016-08-25
    • 2011-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多