I am trying to run the following script and i get an error:
Exception calling "UploadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found."
At C:\config\ftp1.ps1:16 char:22
+ $webclient.UploadFile <<<< ($uri, $item.FullName)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
The script i am trying to run is :
$Dir = "c:\images\"
$ftp = "http:
$user = "username"
$pass = "password"
"ftp url: $ftp"
$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential ($user, $pass)
"Uploading $item..."
foreach($item in (dir $Dir "*.*")){
$uri = New-Object System.Uri($ftp+$item.Name)
"Uploading $item..."
$webclient.UploadFile($uri, $item.FullName)
}
"Upload Complete"
exit
Any ideas would be appreciated, i am pulling my hair out.
Thanks