Skip to content

Instantly share code, notes, and snippets.

@lisadean
Created May 29, 2013 19:49
Show Gist options
  • Save lisadean/5673250 to your computer and use it in GitHub Desktop.
Save lisadean/5673250 to your computer and use it in GitHub Desktop.
FTP function using built-in ftp.exe
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