<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.twig.es/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Using_Powershell_for_ftp_4</id>
		<title>Using Powershell for ftp 4 - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Using_Powershell_for_ftp_4"/>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Using_Powershell_for_ftp_4&amp;action=history"/>
		<updated>2026-05-06T13:10:02Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.0</generator>

	<entry>
		<id>https://wiki.twig.es/index.php?title=Using_Powershell_for_ftp_4&amp;diff=2351&amp;oldid=prev</id>
		<title>George2: Created page with &quot;Reference : http://stackoverflow.com/questions/265339/whats-the-best-way-to-automate-secure-ftp-in-powershell  &lt;source lang=&quot;powershell&quot;&gt;  $sourceuri = &quot;ftp://ftp.secureftp-te...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Using_Powershell_for_ftp_4&amp;diff=2351&amp;oldid=prev"/>
				<updated>2015-08-06T12:50:59Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;Reference : http://stackoverflow.com/questions/265339/whats-the-best-way-to-automate-secure-ftp-in-powershell  &amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt;  $sourceuri = &amp;quot;ftp://ftp.secureftp-te...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Reference : http://stackoverflow.com/questions/265339/whats-the-best-way-to-automate-secure-ftp-in-powershell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$sourceuri = &amp;quot;ftp://ftp.secureftp-test.com/hamlet.zip&amp;quot;&lt;br /&gt;
$targetpath = &amp;quot;C:\hamlet.zip&amp;quot;&lt;br /&gt;
$username = &amp;quot;test&amp;quot;&lt;br /&gt;
$password = &amp;quot;test&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create a FTPWebRequest object to handle the connection to the ftp server&lt;br /&gt;
$ftprequest = [System.Net.FtpWebRequest]::create($sourceuri)&lt;br /&gt;
&lt;br /&gt;
# set the request's network credentials for an authenticated connection&lt;br /&gt;
$ftprequest.Credentials =&lt;br /&gt;
    New-Object System.Net.NetworkCredential($username,$password)&lt;br /&gt;
&lt;br /&gt;
$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile&lt;br /&gt;
$ftprequest.UseBinary = $true&lt;br /&gt;
$ftprequest.KeepAlive = $false&lt;br /&gt;
&lt;br /&gt;
# send the ftp request to the server&lt;br /&gt;
$ftpresponse = $ftprequest.GetResponse()&lt;br /&gt;
&lt;br /&gt;
# get a download stream from the server response&lt;br /&gt;
$responsestream = $ftpresponse.GetResponseStream()&lt;br /&gt;
&lt;br /&gt;
# create the target file on the local system and the download buffer&lt;br /&gt;
$targetfile = New-Object IO.FileStream ($targetpath,[IO.FileMode]::Create)&lt;br /&gt;
[byte[]]$readbuffer = New-Object byte[] 1024&lt;br /&gt;
&lt;br /&gt;
# loop through the download stream and send the data to the target file&lt;br /&gt;
do{&lt;br /&gt;
    $readlength = $responsestream.Read($readbuffer,0,1024)&lt;br /&gt;
    $targetfile.Write($readbuffer,0,$readlength)&lt;br /&gt;
}&lt;br /&gt;
while ($readlength -ne 0)&lt;br /&gt;
&lt;br /&gt;
$targetfile.close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>George2</name></author>	</entry>

	</feed>