Reputation: 464
I tried using this sample i got from a post here like : I'm using powershell 2.0
$File = "D:\28.csv"
$ftp = "ftp://username:Pwd@IPAddress/in/28.csv"
"ftp url: $ftp"
$webclient = New-Object System.Net.WebClient
$uri = New-Object System.Uri($ftp)
"Uploading $File..."
$webclient.UploadFile($uri,$File)
I'm trying to upload a file to an FTP server But i keep getting the error:
Exception calling "UploadFile" with "2" argument(s): "An exception occurred during a WebClient request."
At D:\Scripts\test.ps1:14 char:22
+ $webclient.UploadFile <<<< ($uri,$File)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Upvotes: 4
Views: 13870
Reputation: 1969
it will accept a string as the first parameter as well as System.Uri:
UploadFile Method byte[] UploadFile(string address, string fileName)
you could try this:
$webclient.UploadFile($ftp,$File)
Saw your comment after posting - you should edit you're question to include that info.
Have a look at this:
The gist:
After a bit of investigation, I found that the error was happening because the method call from SQL Server was attempting to use the HttpProxy on the Server machine. If the proxy is not set to null explicitly in your code, then you will get this error.
Upvotes: 1