Solved

Use Powershell script to ftp

Posted on 2016-09-26
10
102 Views
Last Modified: 2016-10-19
I have to FTP a  file on serverA  (c:\customer.txt)  to serverB  (c:\Customerb.txt )
The ftp server has an Ip of 22.22.22.22 username of test123 and password test123
I am looking into a powershell script to achieve this.  Inputs appreciated.
0
Comment
Question by:Nana Hemaa
  • 5
  • 4
10 Comments
 
LVL 23

Accepted Solution

by:
Erik Bjers earned 250 total points
ID: 41817140
Do you want a script to connect to the FTP server, what do you want to do after connecting?

Here is a site with some info on scripting this

http://www.thomasmaurer.ch/2010/11/powershell-ftp-upload-and-download/
0
 
LVL 69

Assisted Solution

by:Qlemo
Qlemo earned 250 total points
ID: 41817604
Using FTPWebRequest is one way to perform FTP up/downloads, but for simple cases you can still rely on the FTP commandline tool.
@"
open 22.22.22.22
user test123 test123
binary
put c:\customer.txt c:\Customerb.txt
"@ | ftp -n -i -v

Open in new window

0
 

Author Comment

by:Nana Hemaa
ID: 41823899
Where do I execute below commands from?

@"
open 22.22.22.22
user test123 test123
binary
put c:\customer.txt c:\Customerb.txt
"@ | ftp -n -i  -v
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 69

Expert Comment

by:Qlemo
ID: 41823996
As requested, it is a PowerShell script.
0
 

Author Comment

by:Nana Hemaa
ID: 41824098
sorry ftp commandline tool confused me.  
I get "port command successful" filename invalid.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 41824120
Run
  ftp -n -i  -v
and then paste line by line to locate which part causes the error.
0
 

Author Comment

by:Nana Hemaa
ID: 41824148
I do not understand what you want me do...Do you have a link where I can read and understand the  -n -1  -v or can you explain please ..
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 41824168
You just run
ftp -n -v -i

Open in new window

in a cmd or PowerShell prompt. That starts FTP without trying to connect and log in, and does not display a prompt.
Then you take each line of the commands above, one by one, i.e.
open 22.22.22.22

Open in new window

and so on. and paste them into the (silent) prompt, until you get the error you showed. Then tell us the line causing this.
This is required because I have no clue where the error results from, and cannot test as each FTP server behaves different.
0
 

Author Comment

by:Nana Hemaa
ID: 41824189
ok thanks will update
0
 

Author Closing Comment

by:Nana Hemaa
ID: 41850716
Could not use the solution.  Just wanted to close case
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question