Link to home
Start Free TrialLog in
Avatar of iaakadmin
iaakadmin

asked on

PowerShell FTP Files

I am trying to move my files that I back nightly onto a local server to one of my hosted servers.  I have created this file in PowerShell script but am getting the below errors.  The server on the other end is 2K3 running FieZilla.

# locate all backup files
Foreach($File in Get-Childitem "\\ServerName\ServerBackups\SQL\db\" -recurse)
{
      # upload all the files
      
    $ftp = "ftp://username_backup:password@compass.mycompany.com/" + $File
    "ftp url: $ftp"

    $webclient = New-Object System.Net.WebClient
    $uri = New-Object System.Uri($ftp)

     "Uploading $File..."
      $webclient.UploadFile($uri, $File)
}

And here is the error I get

ftp url: ftp://username_backup:password@compass.mycompany.com/backup_201104081800.bak
Uploading backup_201104081800.bak...
Exception calling "UploadFile" with "2" argument(s): "An exception occurred during a WebClient request."
At line:13 char:23
+     $webclient.UploadFile <<<< ($uri, $File)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
 
ftp url:ftp://username_backup:password@compass.mycompany.com/backup_201104101800.bak
Uploading backup_201104101800.bak...
Exception calling "UploadFile" with "2" argument(s): "An exception occurred during a WebClient request."
At line:13 char:23
+     $webclient.UploadFile <<<< ($uri, $File)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
ASKER CERTIFIED SOLUTION
Avatar of AlexPace
AlexPace
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Guy Hengel [angelIII / a3]
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.