Created
May 29, 2013 19:49
-
-
Save lisadean/5673250 to your computer and use it in GitHub Desktop.
FTP function using built-in ftp.exe
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 FTP-File($FTPserver, $FTPusername, $FTPpassword, $FTPfile){ | |
#Build FTP script file and run FTP command | |
"open $FTPserver" | Out-File ftp.scr -Encoding ASCII | |
$FTPusername | Out-File ftp.scr -Encoding ASCII -Append | |
$FTPpassword | Out-File ftp.scr -Encoding ASCII -Append | |
"put " + $FTPfile | Out-File ftp.scr -Encoding ASCII -Append | |
"quit" | Out-File ftp.scr -Encoding ASCII -Append | |
ftp.exe -s:ftp.scr | |
Remove-Item ftp.scr | |
} | |
FTP-File "10.0.0.250" "username" "password" "c:\testfile.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment