$infographie="C:\Archive\Infographie\28052013\myfile.pdf"
$ftp = "ftp://174.9.102.210/public_html/infographie/myfile.pdf"
$user = "****"
$pass = "*******"
$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)
$uri = New-Object System.Uri($ftp)
try{
$webclient.UploadFile($uri, $infographie)
}
catch
{
Write-Host "`nAn Error occured while uploading file to: $Uri"
Throw
}
每次我尝试执行脚本时都会遇到问题,我尝试了很多解决方案,但没有一个解决了我的问题。
Exception calling "UploadFile" with "2" argument(s): "An exception occurred during
a ebClient request."
At D:\Scripts\test.ps1:14 char:22
+ $webclient.UploadFile <<<< ($uri,$File)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
当我使用FileZilla时,它似乎使用代理ixftp.e-i.net:8011并且正常工作。我不知道如何在PowerShell中设置代理。