<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://piszczynski.com/index.php?action=history&amp;feed=atom&amp;title=Winscp</id>
	<title>Winscp - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://piszczynski.com/index.php?action=history&amp;feed=atom&amp;title=Winscp"/>
	<link rel="alternate" type="text/html" href="http://piszczynski.com/index.php?title=Winscp&amp;action=history"/>
	<updated>2026-10-27T06:11:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>http://piszczynski.com/index.php?title=Winscp&amp;diff=915&amp;oldid=prev</id>
		<title>Aleks at 11:36, 4 December 2023</title>
		<link rel="alternate" type="text/html" href="http://piszczynski.com/index.php?title=Winscp&amp;diff=915&amp;oldid=prev"/>
		<updated>2023-12-04T11:36:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:36, 4 December 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l33&quot;&gt;Line 33:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 33:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$session.PutFiles(&amp;quot;$uploadpath\*&amp;quot;, &amp;quot;$uploadDestination/&amp;quot;, $false, $transferOptions)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$session.PutFiles(&amp;quot;$uploadpath\*&amp;quot;, &amp;quot;$uploadDestination/&amp;quot;, $false, $transferOptions)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;the parameters are as follows:  local path to files to upload, destination directory on sftp server, remove files from source on successful transfer, transfer options&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;the parameters are as follows:  local path to files to upload, destination directory on sftp server, remove files from source on successful transfer, transfer options&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=== Download files ===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;files can be downloaded using the GetFiles method:&amp;lt;syntaxhighlight lang=&quot;powershell&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;$transferOptions = New-Object WinSCP.TransferOptions&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;$session.GetFiles($($file.FullName), &quot;$localPath\$($file.name)&quot;, $false, $transferOptions)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/syntaxhighlight&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Aleks</name></author>
	</entry>
	<entry>
		<id>http://piszczynski.com/index.php?title=Winscp&amp;diff=914&amp;oldid=prev</id>
		<title>Aleks: Created page with &quot;==WinSCP automation with powershell== Powershell can be used to automate the upload and download of files from sftp servers using the .NET assembly   === Setup Session: === Setup the SFTP session using the following code, you will need to have the winscp automation package stored on the server somewhere:&lt;syntaxhighlight lang=&quot;powershell&quot;&gt; # Define the path to the WinSCP .NET assembly DLL $winscpPath = &quot;C:\Automation\WinSCP-6.1.2-Automation\WinSCPnet.dll&quot; # Update this pa...&quot;</title>
		<link rel="alternate" type="text/html" href="http://piszczynski.com/index.php?title=Winscp&amp;diff=914&amp;oldid=prev"/>
		<updated>2023-12-04T11:32:16Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==WinSCP automation with powershell== Powershell can be used to automate the upload and download of files from sftp servers using the .NET assembly   === Setup Session: === Setup the SFTP session using the following code, you will need to have the winscp automation package stored on the server somewhere:&amp;lt;syntaxhighlight lang=&amp;quot;powershell&amp;quot;&amp;gt; # Define the path to the WinSCP .NET assembly DLL $winscpPath = &amp;quot;C:\Automation\WinSCP-6.1.2-Automation\WinSCPnet.dll&amp;quot; # Update this pa...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==WinSCP automation with powershell==&lt;br /&gt;
Powershell can be used to automate the upload and download of files from sftp servers using the .NET assembly &lt;br /&gt;
&lt;br /&gt;
=== Setup Session: ===&lt;br /&gt;
Setup the SFTP session using the following code, you will need to have the winscp automation package stored on the server somewhere:&amp;lt;syntaxhighlight lang=&amp;quot;powershell&amp;quot;&amp;gt;&lt;br /&gt;
# Define the path to the WinSCP .NET assembly DLL&lt;br /&gt;
$winscpPath = &amp;quot;C:\Automation\WinSCP-6.1.2-Automation\WinSCPnet.dll&amp;quot; # Update this path as needed&lt;br /&gt;
# Load the WinSCP .NET assembly&lt;br /&gt;
Add-Type -Path $winscpPath&lt;br /&gt;
# Create a SessionOptions object with SFTP settings&lt;br /&gt;
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{&lt;br /&gt;
        Protocol = [WinSCP.Protocol]::Sftp&lt;br /&gt;
        HostName = $sftpHost&lt;br /&gt;
        PortNumber = $sftpPort&lt;br /&gt;
        UserName = $sftpUsername&lt;br /&gt;
        Password = $sftpPassword &lt;br /&gt;
        SshHostKeyFingerprint = &amp;quot;&amp;lt;ssh fingerprint of the sftp server&amp;gt;&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Once you have the session options configured you can connect to the SFTP server using the following command:&amp;lt;syntaxhighlight lang=&amp;quot;powershell&amp;quot;&amp;gt;&lt;br /&gt;
# Connect to the SFTP server&lt;br /&gt;
$session.Open($sessionOptions)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Get details of files on server ===&lt;br /&gt;
Use the enumerateremotefiles method to get the details of the files on the sftp server&amp;lt;syntaxhighlight lang=&amp;quot;powershell&amp;quot;&amp;gt;&lt;br /&gt;
$remoteFiles = $session.EnumerateRemoteFiles($remotePath, $null, [WinSCP.EnumerationOptions]::AllDirectories)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upload Files ===&lt;br /&gt;
You can upload files using the PutFiles method:&amp;lt;syntaxhighlight lang=&amp;quot;powershell&amp;quot;&amp;gt;&lt;br /&gt;
$transferOptions = New-Object WinSCP.TransferOptions&lt;br /&gt;
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary&lt;br /&gt;
$session.PutFiles(&amp;quot;$uploadpath\*&amp;quot;, &amp;quot;$uploadDestination/&amp;quot;, $false, $transferOptions)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;the parameters are as follows:  local path to files to upload, destination directory on sftp server, remove files from source on successful transfer, transfer options&lt;/div&gt;</summary>
		<author><name>Aleks</name></author>
	</entry>
</feed>