Last active
April 25, 2019 15:21
-
-
Save atao/89fa3b79cdf3ed574f0c1c3adc4e3394 to your computer and use it in GitHub Desktop.
function SendByFTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SendByFTP { | |
param ( | |
$userFTP = "anonymous", | |
$passFTP = "anonymous", | |
[Parameter(Mandatory=$True)]$serverFTP, | |
[Parameter(Mandatory=$True)]$localFile, | |
[Parameter(Mandatory=$True)]$remotePath | |
) | |
if(Test-Path $localFile){ | |
$remoteFile = $localFile.Split("\")[-1] | |
$remotePath = Join-Path -Path $remotePath -ChildPath $remoteFile | |
$ftpAddr = "ftp://${userFTP}:${passFTP}@${serverFTP}/$remotePath" | |
$browser = New-Object System.Net.WebClient | |
$url = New-Object System.Uri($ftpAddr) | |
$browser.UploadFile($url, $localFile) | |
} | |
else{ | |
Return "Unable to find $localFile" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment