ftp/Simple.ps1

#########################################################
# 
# Summary: 
# This script demonstrates the following features:
# - Connect
# - Download of file
# - Read drectory (enumeration)
# - Disconnect
#
# Notes:
# If you get the following error:
# "cannot be loaded because the execution of scripts is disabled on this system."
# Enable the execution of scripts:
# Set-ExecutionPolicy RemoteSigned
#
# Technical support: support@smartftp.com
#
# Copyright (c) by SmartSoft Ltd.
#########################################################

# If you want to use the interop assembly (you need to create it first) use:
# [Reflection.Assembly]::LoadWithPartialname("Interop.sfFTPLib") | out-null
# For more information: http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan09/hey0126.mspx

# Creates new COM object
$ftp = new-object -com sfFTPLib.FTPConnectionMTA;
$ftp.Host = "ftp.smartftp.com";
$ftp.Port = 21; 
$ftp.Username = "anonymous";
$ftp.Password = "test@test.com";
$ftp.Passive = 1;
# $ftp.LogFile.File = "C:\test.log";

$ftp.Connect();
Write-Host "Connected";
$ftp.ChangeDirectory("/SmartFTP");
foreach($item in $ftp.ReadDirectory())
{
	Write-Host ("Name={0}, Type={1}, Size={2}, ModifyTime={3}" -f $item.Name, $item.Type, $item.Size, [System.DateTime]::FromOADate($item.ModifyTimeAsDate).ToString("o"))
}
		
$ftp.DownloadFile("License.txt", "License.txt", 0,0);
Write-Host "DownloadFile succeeded"
$ftp.Disconnect();