Re: Multiple connections using single sessionOptions
This looks like a simple PowerShell programming question, not a WinSCP question. Are you looking for this?
Though I do not see the point of the "Active" type. It should be merged with the "Ftp" type:
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::$Protocol
HostName = $HostName
PortNumber = $PortNumber
UserName = $UserName
}
if($ConnectionType -eq 'SftpSSH')
{
$sessionOptions.SshHostKeyFingerprint = $SshHostKeyFingerprint
$sessionOptions.SshPrivateKeyPath = $SshPrivateKeyPath
$sessionOptions.PrivateKeyPassphrase = $PrivateKeyPassphrase
}
if($ConnectionType -eq 'Ftp')
{
$sessionOptions.Password = $Password
}
if($ConnectionType -eq 'Active')
{
$sessionOptions.FtpMode = [WinSCP.FtpMode]::$FtpMode
}
Though I do not see the point of the "Active" type. It should be merged with the "Ftp" type:
if($ConnectionType -eq 'Ftp')
{
$sessionOptions.Password = $Password
$sessionOptions.FtpMode = [WinSCP.FtpMode]::$FtpMode
}