I am using PowerShell Scripts to upload the files by FTP. The scripts I use is following:
$File = "C:\test\test01.txt"
$ftp = "ftp://MyUsername:MyPassword@MyHostName/"
"ftp url: $ftp"
$webclient = New-Object System.Net.WebClient
$uri = New-Object System.Uri($ftp)
"Uploading $File..."
$webclient.UploadFile($uri,$File)
But When I run the scripts, I get the following errors:
Exception calling "UploadFile" with "2" argument(s): "The requested URI is invalid for this FTP command."
At C:\FTP.ps1:11 char:1
+ $webclient.UploadFile($uri,$File)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
The Powershell Version I use is following:
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
Anyone knows how to solve this problem?
Thanks