Topic "EnumerateRemoteFiles hangs on Server 2012"

Author Message
[View user's profile]

Joined: 2016-08-10
Posts: 2

So I'm using the WinSCP .net assembly to download files from a PowerShell application. I'm trying to utilize the beta version 5.8.3, which I downloaded about two months ago. I'm utilizing that beta version because it contains the EnumerateRemoteFiles function which I can use to get the total size of files to be downloaded. That total size is then used as a compare value in a progress bar which allows me to know the percentage of data downloaded, and when the download is completed. My code works perfectly fine in Windows 7, where I wrote it, but recently I tested the application in Windows Server 2012 and the code consistently hangs at the first EnumerateRemoteFiles function and cannot continue. I'm wondering if this is an issue with WinSCP, I believe the code is fine since it works in Windows 7, or if it this is a server setup issue which I need to account for. Below is the code I'm using which hangs.

$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::ftp
HostName = $server
UserName = $username
Password = $password
PortNumber = "990"
ftpmode = "Active"
ftpsecure = "Implicit"
$session = New-Object WinSCP.Session

##This is the code which hangs##
$sFTPFiles =
"/ftpFolder/", $Null,
([WinSCP.EnumerationOptions]::EnumerateDirectories -bor [WinSCP.EnumerationOptions]::AllDirectories))

$totalBytes = ($sFTPFiles | Measure-Object -Property Length -Sum).Sum

$MSIArray =
"/ftpFolder/", $Null,
([WinSCP.EnumerationOptions]::EnumerateDirectories -bor [WinSCP.EnumerationOptions]::AllDirectories)) |
Where-Object {$ -like '*.msi' -and $_.fullname -like "*/ftpFolder/*"}
$MSIArray = $MSIArray | Select -Unique

ForEach ($i in $MSIArray)
$sFTPMSIFile = $ -Replace ".msi"
[void] $selectBox.Items.Add($sFTPMSIFile)

Return $totalBytes
[View user's profile]

Joined: 2016-08-10
Posts: 2
I was able to resolve this issue myself. For future people, the issue was with the windows firewall. For some reason the server was not prompting to allow connections for this program as it was in Windows 7. I was able to resolve it by adding some code to create a firewall rule before the EnumerateRemoteFiles function is called.

You can post new topics in this forum


What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License