Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

Upload File FTP

$
0
0

I am building a script that takes a file and then uploads it FTP. The problem I am having is I keep getting an error 530. Here is the function I created to do this. Note I xxx in sensitive data

 

functionftpFile {

 

 

$userName='xxxxxxx'

 

 

 

 

 

 

 

 

 

 

 

 

$password='xxxxxxxxx'

 

 

 

$source="\\xxx\xxxx\\xxxxxx.xls"

 

 

 

$destination="ftp://xxx.xxxx.xxx/xxxxxx.xls"

 

 

 

$cred=New-ObjectSystem.Management.Automation.PSCredential-ArgumentList @($userName,(ConvertTo-SecureString-String$password-AsPlainText-Force

))

 

 

 

$wc=New-Object

System.Net.WebClient

 

 

 

$wc.Credentials =

$cred

 

 

 

$wc.UploadFile($destination,$source)

 

 

 

$wc.Dispose();

 

 

 

Write-Host-ForegroundColorGreen"FTP upload successful!"

}


Viewing all articles
Browse latest Browse all 8411

Trending Articles